-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP50.java
More file actions
52 lines (39 loc) · 1.22 KB
/
P50.java
File metadata and controls
52 lines (39 loc) · 1.22 KB
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
/**
* P50 : 50 امین عدد اول
*
* @author Gholamali Nejad Hajali Irani
* @version 1.0
* @since 2021/01/02
* @Team gClassAcademy
* @Website https://www.youtube.com/c/gClassAcademy
*/
import java.util.Scanner;
public class P50
{
public static void main(String[] args)
{
Scanner input=new Scanner (System.in);
int primecount=0; //برای شمارش تعداد اعداد اول
int n=0; //عددی که هر بار اول بودن آنرا بررسی میکنیم
while (primecount<50)
{
n++;
// بررسی اول بودن عدد n
int count=0; //برای تعداد مقسوم علیه ها
for (int x=1;x<=n;x++)
if (n%x==0)
count++;
if (count==2)
{
primecount++;
}
}//end of while primecount
System.out.println(n);
/*
* for (int n=1;n<=100000;n++) { // بررسی اول بودن عدد n int count=0; //برای
* تعداد مقسوم علیه ها for (int x=1;x<=n;x++) if (n%x==0) count++; if (count==2)
* { primecount++; if (primecount==500) { System.out.println(primecount + ":" +
* n); break; } } }// end of for n
*/
}// end of main
}// end of class