43) Write a program to input a number and
find it’s all Prime Factor and print
it?(12==2,2,3….all factors are prime)
import java.util.*;public class Prime_factor{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();int t = a/2;System.out.print("PRIME FACTOR of "+a+" = ");
if(a==1){System.out.println(a);}
for(int i = 2;i<=t;){if(a%i==0){System.out.print(i+" ");a=a/i;}else{i++;}}
}}
Output :
prime-factor-of-a-number Write a program to input a number and
find the Primorial of this number? (6=
2, 3, 5 à2*3*5=30) |