Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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
       }
   }
}
 
PREVIOUS NEXT
Tagged: #calculate #prime #factors #number #java
ADD COMMENT
Topic
Name
3+4 =