Advertisement
Josif_tepe

Untitled

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