Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. //tested by Hightail www.github.com/dj3500/hightail
  2. #include <bits/stdc++.h> //oh que me suspenden
  3. using namespace std;
  4.  
  5. bool es_poderos(int n) {
  6.     int fact = 2;
  7.     while(n>1 and fact*fact<=n) {
  8.         int kfact = 0;
  9.         while(n%fact==0) {
  10.             n/=fact;
  11.             ++kfact;
  12.         }
  13.         if(kfact==1) return false;
  14.         ++fact;
  15.     }
  16.     return n==1;
  17. }
  18.  
  19. int main() {
  20.     int n;
  21.     while(cin >> n) {
  22.         bool first = true;
  23.         for(int i=1; i<=n; ++i) {
  24.             if(es_poderos(i)) {
  25.                 if(not first) cout << ',';
  26.                 first = false;
  27.                 cout << i;
  28.             }
  29.         }
  30.         cout << endl;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement