arrow_forward
همه ارسالها
جزئیات ارسال کد#595
برای پسندیدن وارد شوید
1#include <iostream>
2#include <math.h>
3using namespace std;
4int main()
5{
6 long long int n; cin >> n;
7 int counter = 1;
8 int a = 2;
9 int b = sqrt (n);
10 if ( n > 2 )
11 {
12 while ( a < b )
13 {
14 if ( n % a == 0 )
15 {
16 cout << "Composite";
17 break;
18 }
19
20 else
21 {
22 if ( a + 1 >= b )
23 {
24 cout << "Prime";
25 }
26
27 a ++;
28 }
29 }
30 }
31
32 else
33 {
34 if ( n == 1 )
35 {
36 cout << "Nothing";
37 }
38
39 else if ( n == 2 )
40 {
41 cout << "Prime";
42 }
43 }
44
45
46
47 return 0;
48}
کد ارسالشده برای داوری خودکار هاتکدز
UTF-8