+ 1
QUESTION IN THE CODE ITSELF
import java.util.*; public class prime_factors { public static void main() { Scanner sc=new Scanner(System.in); int n; int k=2; System.out.println("\n\nEnter a number"); n=sc.nextInt(); System.out.println("\n\nThe Prime Factors of "+n+ " are :"); for(;k<=n;)//what is the meaning of this loop { if(n%k==0) { System.out.print("\n"+k+" "); n/=k; } else k++; } } } I will be obliged if it is explained to me that how this code works
3 Respostas
+ 2
First of all as zemiak already mentioned you forgot arguments for the main function. Regarding question and explanation you can find it in the comments in the code:
https://code.sololearn.com/cm8AUGD4z67s/?ref=app
+ 2
@Aleksei Radchenkov Thanks Brother for the explaination , hail the sololearn community!
0
this code not works, because main() has not parameter
//public static void main( )
public static void main( String[] args)