分享

095.奇数平方的有趣性质

 C语言与CPP编程 2022-05-03 发布于安徽
#include<stdio.h>
void main()
{
    long int a,n=0;
    clrscr();
    puts("***********************************************************");
    puts("*      >>      This program is to verify       <<         *");   
    puts("*      >>     odd number's characteristic.     <<         *");
    puts("* That is square of an odd number larger than 1000 minus  *");
    puts("* 1 can be divided exactly by 8.                          *");
    puts("* For example, 2001^2-1=4004000=500500*8.                 *");
    puts("***********************************************************");
    while(n<1001)
    {
    	printf(" >> Please input the range you want to verify: ");
    	scanf("%ld",&n);
    }
    puts(" >> Now start to verify:");
    for(a=1001;a<=n;a+=2)
    {
        printf("%ld:",a);       /*输出奇数本身*/
        printf("(%ld*%ld-1)/8",a,a);      /*输出(奇数的平方减1)/8*/
        printf("=%ld",(a*a-1)/8);        /*输出被8除后的商*/
        printf("+%ld\n",(a*a-1)%8);      /*输出被8除后的余数*/
    }
    puts("\n Press any key to quit...");
    getch();
}

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多