-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsum-prime.c
79 lines (69 loc) · 1.39 KB
/
sum-prime.c
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdio.h>
#include <stdlib.h>
int prime_checkr(int num)
{
int num1,num2, temp=0;
for (int i=2; i<=num/2; i++)
{
int prime1 = 1;
for (int j=2; j<i; j++)
{
if(i==j)
{
continue;
}
if (i%j == 0)
{
prime1 = 0;
break;
}
else
{
prime1=1;
continue;
}
}
if (prime1==1)
{
num1=i;
num2= num-num1;
int prime2;
for (int j_2=2; j_2<num2; j_2++)
{
if(j_2==num2)
{
continue;
}
if (num2%j_2 == 0)
{
prime2 = 0;
break;
}
else
{
prime2=1;
continue;
}
}
temp=prime2;
if(temp==1)
break;
}
}
return(temp);
}
int main()
{
int num;
printf("Enter the number: \n");
scanf("%d",&num);
if (prime_checkr(num) == 1)
{
printf("Yes! the number can be expressed.\n");
}
else
{
printf("NO! the number can Not be expressed.\n");
}
return 0;
}