wap in java to input any no. then print its prime factors excluding 1
Answers
Answered by
2
Answer:
import java.util.*;
public class
{
public static void main(String args[])
{
int n;
Scanner anime = new Scanner(System.in);
System.out.println("Enter a number =");
n = anime.nextInt();
for(int i = 2; i< n; i++)
{
while(n%i == 0)
{
System.out.println(i+" ");
n = n/i;
}
}
if(n >2)
{
System.out.println(n);
}
}
}
Explanation:
//forgive me if its wrong :)
Similar questions