35 lines
714 B
C
35 lines
714 B
C
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
#include <math.h>
|
|
|
|
bool isPrime(int toBeTested){
|
|
int iterationMax = 0, nowCheck = 2;
|
|
bool isPrime = true;
|
|
iterationMax = sqrt(toBeTested);
|
|
do {
|
|
if (toBeTested % nowCheck == 0) {
|
|
isPrime = false;
|
|
break;
|
|
}
|
|
nowCheck++;
|
|
}
|
|
while (nowCheck <= iterationMax);
|
|
return isPrime;
|
|
}
|
|
|
|
int main() {
|
|
int n, p1;
|
|
scanf("%d", &n);
|
|
if (n < 4 || n % 2 == 1) {
|
|
printf("input error");
|
|
}
|
|
else {
|
|
for (p1=3;;p1+=2) {
|
|
if (isPrime(p1) && isPrime(n - p1)) {
|
|
printf("%d = %d + %d", n, p1, n-p1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
} |