Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int f(int x);
- int main(void) {
- int x;
- printf("Введите число: ");
- scanf("%d", &x);
- if(f(x) == 1)
- printf("Число простое\n");
- else
- printf("Число составное\n");
- return 0;
- }
- int f(int x) {
- int primality = 1;
- for(int i = 2; (i <= sqrt(x)) && (primality == 1); ++i) {
- if(x % i == 0)
- primality = 0;
- }
- return primality;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement