- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP70.java
60 lines (39 loc) · 1.17 KB
/
P70.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* P70 : چاپ جمع مقسوم علیه های اول یک عدد
*
* @author Gholamali Nejad Hajali Irani
* @version 1.0
* @since 2021/01/19
* @Team gClassAcademy
* @Website https://www.youtube.com/c/gClassAcademy
*
*/
importjava.util.Scanner;
publicclassP70
{
publicstaticvoidmain(String[] args)
{
Scannerinput=newScanner (System.in);
System.out.println("Enter n:");
intn=input.nextInt(); // عددی که از کاربر گرفته می شود
intallcount=0; //تعداد مقسوم علیه های اول
intsum=0; //جمع مقسوم علیه های اول
for (intx=1;x<=n;x++)
if (n%x==0) // اگر x مقسوم علیه بود
{
// بررسی اول بودن x
intcount=0;
for (inty=1;y<=x;y++)
if (x%y==0)
count++;
if (count==2) //x اول هست
{
System.out.println(x);
allcount++;
sum+=x;
}
}//end of if n%x==0
System.out.println("Count of Primes is: " + allcount);
System.out.println("Sum of Primes is: " + sum);
}// end of main
}// end of class