Jump to content

Recommended Posts

Posted

Acum cateva zile am auzit ca Java se aseamana foarte mult cu C++ doar ca Java e orientat mai mult pe programarea pe obiecte.


public class Proiect {
	public static void main(String[] args) {
		int n=18,flag=1,d;
		if(n%2==0) flag=0;
		else
		{
			for(d=3;d*d<=n;d+=2);
			{
				if(n%d==0) flag=0;
				else flag=1;
			}
		}
		if(flag==1) System.out.println("Da.");
		else System.out.println("Nu.");		
	}

}

Faza e ca vreau sa pot citi si un nr. Am cautat pe net si nici una dintre metode nu a mers. Ma poate ajuta cineva?

Respecta si vei fi respectat.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.