-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacPrime.java
40 lines (33 loc) · 910 Bytes
/
facPrime.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.Scanner;
public class facPrime {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("Enter a number: ");
int num =sc.nextInt();
System.out.println("factorials are: ");
for(int i=1; i<=num;i++)
{
if (num%i==0)
{
System.out.println(" " + i) ;
}}
System.out.println("prime are:");
for (int i=2; i<=num; i++) {
if(num%i==0)
{
boolean isPrime=true;
for(int j=2; j<i; j++) {
if(i%j==0) {
isPrime=false;
break;
}
}
if(isPrime) {
System.out.println(i);
}
}
{
}
}
}
}