JOHNYTHEWINNER

Digits counter - special numbers/prime

Feb 18th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <string>
  7.  
  8. int main()
  9. {
  10.     int n;
  11.     cin >> n;
  12.     int tempnumber;
  13.     int digitcounter;
  14.     int num;
  15.     for (int i = 1111; i <= 9999; i++) {
  16.         int m = 1;
  17.         num = i;
  18.         int counterforprimes = 0;
  19.         while (m <= 4) {
  20.             digitcounter = num % 10;
  21.             if (digitcounter == 0) {
  22.                 break;
  23.             }
  24.             if (n % digitcounter == 0)
  25.             {
  26.                 counterforprimes++;
  27.             }
  28.             num = num / 10;
  29.             m++;
  30.         }
  31.         if (counterforprimes > 3) {
  32.             cout << i << " ";
  33.         }
  34.     }
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment