Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- bool check(int n)
- {
- int sum = 0;
- for (int i = 1; i < n; i++)
- {
- if (n % i == 0)
- sum += i;
- }
- if (sum == n)
- return true;
- else
- return false;
- }
- int main()
- {
- int a, b;
- scanf("%i %i", &a, &b);
- int count = 0;
- for (int i = a; i <= b; i++)
- {
- if (check(i))
- {
- printf("%i ", i);
- count += 1;
- }
- }
- if (count == 0)
- printf("0");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement