summaryrefslogtreecommitdiff
path: root/euler29.c
blob: a9e5fc5f97d4aaab187b0d0cdc391706efa70d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}