Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main() {
- int sum = 0, n;
- printf("Enter any integer:\n");
- scanf("%d", &n);
- int num = n;
- while (n > 0) {
- sum += (n % 10);
- n /= 10;
- }
- printf("Sum of its digits = %d. ", sum);
- for (int i = 2; i < sum; i++) {
- if (sum % i == 0) {
- printf("It is not a prime number.\n");
- return 0;
- }
- }
- printf("It is a prime number.\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement