Here's an algorithm in java:
import java.util.Scanner;
import java.util.ArrayList;
public class PrimeFactorization
{
public static void main(String[] args)
{
String response;
Scanner scan=new Scanner(System.in);
double num=0;
boolean read=false,run=true;
timer.start();
while(run)
{
System.out.println("Enter a number");
while(!read)
{
response=scan.next();
try
{
num=Double.parseDouble(response);
read=true;
}
catch(NumberFormatException exception)
{
System.out.println("Incorrect Format");
}
}
read=false;
TimerListener.resetT();
ArrayList<Double> list=getPrimeFactorization(num);
System.out.println("Prime Factorization:");
for(int count=0;count<list.size()-1;count++)
{
System.out.print(list.get(count)+", ");
}
System.out.println(list.get(list.size()-1));
System.out.println("Time: "+TimerListener.getT()+"s\n\n");
}
}
public static ArrayList<Double> getPrimeFactorization(double num)
{
ArrayList<Double> list=new ArrayList<Double>();
boolean run=true;
double index;
while (run)
{
list.add(index=getFirstFactor(num));
num=num/index;
if (num==1) run=false;
}
return list;
}
private static double getFirstFactor(double num)
{
for(int count=2;count<=Math.sqrt(num)+1;count++)
{
if ((double)num/(double)count%1==0)return count;
}
return num;
}
The prime factorization of 4 is 2 x 2. It is not possible to find the LCM of a single number.
Find the prime factorization of 16.The prime factorization of 16 is: 2x2x2x2.
101 is already prime; no factorization required.
53 is a prime number so there is no relevant prime factorization for it.
it is easier to find the prime factorization because you do not have to keep multiplying over and over and over again!!!!
find the prime factorization to the number 81
The prime factorization of 15332 • 17153 is not a prime number
Only 23 has prime factorization of 23.
The prime factorization of 6 is 2 x 3.
Since 5 is a prime number, the prime factorization of 5 is simply 5.
The prime factorization of the number 33 is: 3 x 11
Prime factorization is when you find all the prime factors of a number.
prime factorization each number is a part of the whole
29 is a prime number
None. 37 is a prime number.
2x3x5
The prime factorization of 4 is 2 x 2. It is not possible to find the LCM of a single number.