calculate prime factors of a number java

Solutions on MaxInterview for calculate prime factors of a number java by the best coders in the world

showing results for - "calculate prime factors of a number java"
Gordon
18 Apr 2020
1public static void main(String[] args) {
2   	int n=12;
3    for(int i=2; i<=n; i++){ 
4       while(n%i==0){
5         n=n/i;
6         System.out.println(i); //prints 2 2 3
7       }
8   }
9}
Thiago
19 Sep 2019
1import java.util.Scanner;
2
3public class PrimeFactors {
4   public static void main(String args[]){
5      int number;
6      Scanner sc = new Scanner(System.in);
7      System.out.println("Enter a number ::");
8      number = sc.nextInt();
9     
10      for(int i = 2; i< number; i++) {
11         while(number%i == 0) {
12            System.out.println(i+" ");
13            number = number/i;
14         }
15      }
16      if(number >2) {
17         System.out.println(number);
18      }
19   }
20}
queries leading to this page
prime factors javato find the sum of prime factors javafind prime factors of a number javaprime factors of a number code in javaprogram to find prime factors of a number in javasum of prime factors of a number in javaprime factors program in javaprogram to find factors of a number in javaprime factors in javaprime factors of a bigger number in javaprime factors of a number in javaget prime factors of a number javahow to find the prime factors of a number in javadisplay the prime factors of a given positive integer in javahow to find prime factors of a number in javafind prime factor in javaprime factors of a number javamethod to find the prime factor of a given number in javaprime factors of a numbe in javaprogram to find prime factors of a number in java without using sqrtfind all the factors of a number javaprime factors of n in javastore prime factors of a number in array in javahow to get factors of a number in javaprime factors of number in javafinding all the factors of a number in javahow to find the factors of a number in javafind prime factors of number javawrite a program to compute factors of a number n using prime factorization method in javajava program to find factors of a numberhow to get prime factors count of a number in javafind factors in javahow to find prime factors javafinding all the prime factors of a number in javafinding prime factors of a number in javaprime factors code in javaprogram to find the factors of a number in javacalculate prime factors of a number javacalculate prime factors of a number in javajava program to find factors of a given numberfind number prime factors of a number in javaprime factors of a number java prgramfind prime factors of a number in java using stream methodhow to find prime factors in javaall primer factors javaprime factors using javajava program to calculate prime factor of a numberwrite a program to print factors of a number in javahow to measure prime factors in javaprime factor of a number code in javafind prime factors of a number in javaunique prime factors of a number in javaprogram to find prime factors of a number in java with try catchhow to get factors of number javajava program to find the factors of a number in terms of prime numbershow to find factors of a number in javajava get prime factorsfind prime factors of a number in java in c 2b 2bcalculate prime factors of a number java