前几项是:0、2、4、8、12、18、24、32、40、50
…其规律是:对偶数项,是序号平方再除2,奇数项,是序号平方减1再除
2.以下的代码打印出了大衍数列的前 100 项
#include<stdio.h>
int main(){
int a, b;
for(int i=1;i<=100;i++){
if(i%2==0){
a=i*i/2;
printf("%d\n",a);
}else{
b=(i*i-1)/2;
printf("%d\n",b);
}
}
return 0;
}
0
2
4
8
12
18
24
32
40
50
60
72
84
98
112
128
144
162
180
200
220
242
264
288
312
338
364
392
420
450
480
512
544
578
612
648
684
722
760
800
840
882
924
968
1012
1058
1104
1152
1200
1250
1300
1352
1404
1458
1512
1568
1624
1682
1740
1800
1860
1922
1984
2048
2112
2178
2244
2312
2380
2450
2520
2592
2664
2738
2812
2888
2964
3042
3120
3200
3280
3362
3444
3528
3612
3698
3784
3872
3960
4050
4140
4232
4324
4418
4512
4608
4704
4802
4900
5000
--------------------------------
Process exited after 0.5411 seconds with return value 0
请按任意键继续. . .