+ 3
Program not working ...i dont know how to take input at compile time ... through scanner..xan any one find error.
import java.util.Scanner ; class MyClass { public static void main(String[ ] args) { Scanner in=new Scanner (System.in); int n=in.nextint (); for(int i=1;i<=n;i++){ if(n%i==0) { System.out.println(i); } else{ continue ; } } } }
3 ответов
+ 14
You wrote wrong method. Please change to nextInt()
like this:
int n=in.nextInt ();
+ 2
Tnx
0
you can use sc.nextInt() inside the for loop to take multiple inputs