+ 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

30th Sep 2021, 6:00 AM
JusCodin'Bro
3 Antworten
+ 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
30th Sep 2021, 8:35 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
@Aleksei Radchenkov Thanks Brother for the explaination , hail the sololearn community!
30th Sep 2021, 11:35 AM
JusCodin'Bro
0
this code not works, because main() has not parameter //public static void main( ) public static void main( String[] args)
30th Sep 2021, 6:55 AM
zemiak