乐趣区

projecteulerproblem6

problem6

地址:https://projecteuler.net/problem=6。
源码:git@code.aliyun.com:c-program/projecteuler.git。
问题:找到 100 和平方与平方和的差值。

#include <stdio.h>
#include <math.h>
#include "debug.h"

#define NUM 100

int main(int argc, char **argv){
    long int iResult = 0;
    int i, j;

    debugTime();

    for (i = 1; i < NUM; i++){for (j = i + 1; j <= NUM; j++){iResult += i * j;}
    }

    iResult *= 2;
    
    printf("Problem6  Answer: %ld\n", iResult);

    debugTime();

    return 0;
}
退出移动版