answersLogoWhite

0

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;

}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
More answers

All composite numbers can be expressed as unique products of prime numbers. This is accomplished by dividing the original number and its factors by prime numbers until all the factors are prime. A factor tree can help you visualize this.
Example: 210

210 Divide by two.
105,2 Divide by three.
35,3,2 Divide by five.
7,5,3,2 Stop. All the factors are prime.

2 x 3 x 5 x 7 = 210
That's the prime factorization of 210.

User Avatar

Wiki User

12y ago
User Avatar

In number theory, the prime factors of a positive integer are the prime numbers that divide that integer exactly, without leaving a remainder. The process of finding these numbers is called integer factorization, or prime factorization.

User Avatar

Wiki User

14y ago
User Avatar

All composite numbers can be expressed as unique products of prime numbers. This is accomplished by dividing the original number and its factors by prime numbers until all the factors are prime. A factor tree can help you visualize this.
Example: 210

210 Divide by two.
105,2 Divide by three.
35,3,2 Divide by five.
7,5,3,2 Stop. All the factors are prime.

2 x 3 x 5 x 7 = 210
That's the prime factorization of 210.
210 has sixteen factors.
Now that you know that 1, 2, 3, 5 and 7 are factors of 210, you need three more.
2 x 3 = 6
2 x 5 = 10
2 x 7 = 14
Divide all of those into 210 to get the other half.
1, 2, 3, 5, 6, 7, 10, 14, 15, 21, 30, 35, 42, 70, 105, 210

User Avatar

Wiki User

12y ago
User Avatar

There's really only one way to find a prime factorization; divide prime numbers into a given number and its factors until all the factors are prime. There are numerous ways to notate that process. A quick glance through this website reveals continuous division, quotients of 1, Euclidean method, division ladders and the various factor trees, fireworks, rainbows, etc.

User Avatar

Wiki User

12y ago
User Avatar

There are factor trees and ladders and rainbows and fireworks and they're all pretty much the same thing: ways to notate the process of finding the prime factorization of a given number. They differ in where they write the number and where the factors end up. In a factor tree, write the original number at the top and the bottommost branch will be the prime factorization. In a factor rainbow, write the original number at the bottom and the prime factorization will be the uppermost arc.

User Avatar

Wiki User

12y ago
User Avatar

All composite numbers can be expressed as unique products of prime numbers. This is accomplished by dividing the original number and its factors by prime numbers until all the factors are prime. A factor tree can help you visualize this.

Example: 210

210 Divide by two.

105,2 Divide by three.

35,3,2 Divide by five.

7,5,3,2 Stop. All the factors are prime.

2 x 3 x 5 x 7 = 210

That's the prime factorization of 210.

User Avatar

Wiki User

10y ago
User Avatar

Factor trees, rainbows, fireworks, ladders

User Avatar

Wiki User

9y ago
User Avatar

Add your answer:

Earn +20 pts
Q: How can you find the prime factorization of a number?
Write your answer...
Submit
Still have questions?
magnify glass
imp