Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 16, 2017 11:01
#include <iostream>
#include <math.h>
using namespace std;
void P(int a, int b){
if (a > b){
int aux = a;
a = b;
b = aux;
}
int i;
for (i = a; i <= b; i++) {
if (sqrt(i) != (int)sqrt(i) || i == 1)
continue;
int x = sqrt(i),d,ok = 0;
for (d = 2; d <= sqrt(x) && ok == 0; d++)
if (x % d == 0)
ok = 1;
if (ok == 0)
cout<<i<<" ";
}
}
int main() {
int a,b;
cin>>a>>b;
P(a,b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment