diff options
Diffstat (limited to 'euler29.c')
-rw-r--r-- | euler29.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/euler29.c b/euler29.c new file mode 100644 index 0000000..a9e5fc5 --- /dev/null +++ b/euler29.c @@ -0,0 +1,31 @@ +#include <stdio.h> +#define LIMIT 4 + +int d[LIMIT+1][LIMIT+1]={}; +int count=(LIMIT-1)*(LIMIT-1); + +int main() +{ + int a,b,c; + for (a=2;a<=LIMIT;a++){ + int bb=a; + for (b=2;b<=LIMIT;b++){ + bb*=a; + if (bb>LIMIT) break; + for (c=2;c<=LIMIT/b;c++){ + d[bb][c]=1; // (a^b)^c = a^(bc) + } + } + } + for (a=2;a<=LIMIT;a++){ + for (b=2;b<=LIMIT;b++){ + if (d[a][b]){ + printf("%d %d\n",a,b); + --count; + } + } + } + printf("%d\n",count); + return 0; +} + |