RosettaCodeData/Task/Square-but-not-cube/C/square-but-not-cube.c
2023-07-01 13:44:08 -04:00

18 lines
367 B
C

#include <stdio.h>
#include <math.h>
int main() {
int n = 1, count = 0, sq, cr;
for ( ; count < 30; ++n) {
sq = n * n;
cr = (int)cbrt((double)sq);
if (cr * cr * cr != sq) {
count++;
printf("%d\n", sq);
}
else {
printf("%d is square and cube\n", sq);
}
}
return 0;
}