Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //tested by Hightail www.github.com/dj3500/hightail
- #include <bits/stdc++.h> //oh que me suspenden
- using namespace std;
- bool es_poderos(int n) {
- int fact = 2;
- while(n>1 and fact*fact<=n) {
- int kfact = 0;
- while(n%fact==0) {
- n/=fact;
- ++kfact;
- }
- if(kfact==1) return false;
- ++fact;
- }
- return n==1;
- }
- int main() {
- int n;
- while(cin >> n) {
- bool first = true;
- for(int i=1; i<=n; ++i) {
- if(es_poderos(i)) {
- if(not first) cout << ',';
- first = false;
- cout << i;
- }
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement