Advertisement
Josif_tepe

Untitled

Nov 12th, 2023
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <math.h>
  6.  
  7.  
  8. int main(int argc, char * argv[]) {
  9.  
  10.     int a, b;
  11.     scanf("%d%d", &a, &b);
  12.    
  13.     for(int i = a; i <= b; i++) {
  14.         int tmp = i;
  15.         int prevrten = 0;
  16.         while(tmp > 0) {
  17.             int cifra = tmp % 10;
  18.             prevrten = (prevrten * 10) + cifra;
  19.             tmp /= 10;
  20.         }
  21.         int sum = 0;
  22.         for(int j = 1; j < prevrten; j++) {
  23.             if(prevrten % j == 0) {
  24.                 sum += j;
  25.             }
  26.         }
  27.         if(prevrten == sum) {
  28.             printf("%d ", i);
  29.         }
  30.     }
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement