answersLogoWhite

0


Best Answer

import java.io.*;

class PrimeFactors

{

private boolean prime(int a)

{

boolean b=true;

for(int i=2;i<=(a/2);i++)

{

if(a%i==0)

b=false;

}

return b;

}

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the Number: ");

int a=Integer.parseInt(in.readLine());

PrimeFactors o=new PrimeFactors();

System.out.println("Prime Factors of "+a+" are::");

for(int i=1;i<=(a/2);i++)

{

if(a%i==0)

{

boolean b=o.prime(i);

if(b==true)

System.out.print(i+" ");

}

}

}}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in java to print prime factors of a number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a number as a product of its prime factors?

write the number 14as a product of prime factor?


How do write 525 as a product of prime factors?

write the prime factorization of the number. simple as that.


What does 'products of its primes' mean?

To write a composite whole number as the product of its prime factors is to write its prime factorization.


What is it called when you write a number as a product of its factors?

the prime factorization


Is it true or false prime factorization renames a composite number as the product of prime factors?

True(Prime factorization is to write a composite number as a product of its prime factors).


Write the number 256 as a product of prime factors.?

256 = 28


What is the largest prime no that is stored in 8 bit pattern?

Write your own prime number program and find out.


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


How do you write the number 99 as a product of prime factors?

99 as a product of its prime factors is: 3*3*11 or 32*11


How do you write 530 as a prime number?

2 5 53 are the factors of 530


How do i write the number 185 as a product of prime factors?

5 times 37


What do they mean write the prime factorization?

The mean write the number as an expression of its prime factors. The prime factors of 210 are 2, 3, 5 and 7. 2 x 3 x 5 x 7 is the prime factorization of 210.