0% found this document useful (0 votes)
10 views

Import Jav7

The Java program prompts the user to enter a number and then calculates its prime factors. It uses a loop to divide the number by each integer starting from 2, printing each prime factor found. The output for the input number 144 shows the prime factors as 2, 2, 2, 3, 3.

Uploaded by

ghostofekn123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Import Jav7

The Java program prompts the user to enter a number and then calculates its prime factors. It uses a loop to divide the number by each integer starting from 2, printing each prime factor found. The output for the input number 144 shows the prime factors as 2, 2, 2, 3, 3.

Uploaded by

ghostofekn123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

*;

class pfactor

public static void main()

Scanner sc=new Scanner(System.in);

System.out.println("Enter any number to find primefactors");

int number=sc.nextInt();

System.out.println("Given number is:"+number);

System.out.print("Prime factors are:");

for(int i=2;i<=number;i++)

while(number%i==0)

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

number=number/i;

if(number<1)System.out.println(number);

Enter any number to find primefactors

144

Given number is:144

Prime factors are:222233

You might also like