任何一个整数的立方都可以表示成一串连续的奇数的和。
1: #include "stdio.h"
2:
3: void Nicoqish(int N)
4: {
5: int i, j, sum = 0;
6:
7: for(i = 1; i < N * N * N; i = i + 2) /*i为起点*/
8: for(j = i; j < N * N * N; j = j + 2) /*j控制从i向后顺次累加*/
9: {
10: sum = sum + j;
11:
12: if(sum == N * N * N)
13: {
14: printf("%d=%d+%d...+%d\n", N * N * N, i, i + 2, j);
15: return;
16: }
17:
18: if(sum > N * N * N)
19: {
20: sum = 0;
21: break;
22: }
23: }
24: }
25:
26: int main()
27: {
28: int N;
29: printf("Please input a integer to verify Nicoqish Law\n");
30: scanf("%d", &N);
31: Nicoqish(N);
32: return 0;
33: }