Prime Check

Lab C Beginner 10 points

Read n ≥ 2 and print prime or not prime, stopping early with break.

Input

One integer.

Output

One line.

Example

Input

2

Output

prime
Sample input available Sample output available
Editor
C

Hints

Only test divisors while d * d <= n.

Solution explanation

C has no boolean type by default; an int flag 1/0 does the job.

Show solution
#include <stdio.h>

int main() {
    int n, prime = 1;
    scanf("%d", &n);
    for (int d = 2; d * d <= n; d++) {
        if (n % d == 0) {
            prime = 0;
            break;
        }
    }
    printf(prime ? "prime\n" : "not prime\n");
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD