Answers for "method to find the prime factor of a given number in Java"

4

calculate prime factors of a number java

public static void main(String[] args) {
   	int n=12;
    for(int i=2; i<=n; i++){ 
       while(n%i==0){
         n=n/i;
         System.out.println(i); //prints 2 2 3
       }
   }
}
Posted by: Guest on June-17-2021

Code answers related to "method to find the prime factor of a given number in Java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language