Advertisement
Josif_tepe

Untitled

Mar 21st, 2024
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.    
  5.     int a, b;
  6.     scanf("%d%d", &a, &b);
  7.  
  8.     for(int i = a; i <= b; i++) {
  9.         int tmp = i, zbir = 0;
  10.  
  11.         while(tmp > 0) {
  12.             int cifra = tmp % 10;
  13.             zbir += cifra;
  14.             tmp /= 10;
  15.         }
  16.         int deliteli = 0;
  17.         for(int j = 1; j <= zbir; j++) {
  18.             if(zbir % j == 0) {
  19.                 deliteli++;
  20.             }
  21.         }
  22.         if(deliteli <= 2) {
  23.             printf("%d ", i);
  24.         }
  25.  
  26.     }
  27.        return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement