Advertisement
halexandru11

var 39 s3 ex 4

Dec 3rd, 2020
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. unsigned int pr(unsigned int x) {
  7.     if(x < 2) {
  8.         return 0;
  9.     }
  10.     for(unsigned int div = 2; div*div <= x; ++div) {
  11.         if(x%div == 0) {
  12.             return 0;
  13.         }
  14.     }
  15.     return 1;
  16. }
  17.  
  18. int main() {
  19.     ifstream fin("date.in");
  20.     unsigned int n;
  21.     fin >> n;
  22.     while(n >= 100) {
  23.         n /= 10;
  24.         if(pr(n)) {
  25.             cout << n << " ";
  26.         }
  27.     }
  28. }
  29.  
Advertisement
RAW Paste Data Copied
Advertisement