验证尼科彻斯定理,即:任何一个整数m的立方都可以写成m个连续奇数之和。
例如:
1^3=1
2^3=3+5
3^3=7+9+11
4^3=13+15+17+19
输入一个正整数m(m≤100),将m的立方写成m个连续奇数之和的形式输出。
输入描述:输入一个int整数
输出描述:输出分解后的string
输入:6
输出:
31+33+35+37+39+41
//: Find the rule between output with n, found print n nums, and start = n * n - n + 1, and increase with common step
#include <stdio.h>
int main()
{
int n;
while (scanf("%d", &n) != EOF) {
int start = n * n - n + 1;
printf("%d", start);
int i;
for (i = 1; i < n; i++) {
printf("+%d", start + 2 * i);
}
printf("\n");
}
return 0;
}