Advertisement
Josif_tepe

Untitled

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