尤拉計畫 第十題

2021-08-21 05:11:00 字數 498 閱讀 4373

the sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

find the sum of all the primes below two million.

低於10的素數之和為2 + 3 + 5 + 7 = 17。

找出200萬以下所有素數的總和。

思路這道題與第7題的線性篩思路一樣,只是篩出小於兩百萬的素數的同時進行求和,要記得用int64_t喲

#include #include #define max 2000000 

int main();

int64_t sum = 0;

for(int64_t i = 2; i < max; i++)

for(int64_t j = 1; j <= prime[0]; j++)

} printf("%"prid64"\n", sum);

return 0;

}

尤拉計畫36題

double base palindromes problem 36 the decimal number,585 10010010012 binary is palindromic in both bases.find the sum of all numbers,less than one mi...

23號第十題

小兔的叔叔從外面旅遊回來給她帶來了乙個禮物,小兔高興地跑回自己的房間,拆開一看是乙個棋盤,小兔有所失望。不過沒過幾天發現了棋盤的好玩之處。從起點 0,0 走到終點 n,n 的最短路徑數是c 2n,n 現在小兔又想如果不穿越對角線 但可接觸對角線上的格點 這樣的路徑數有多少?小兔想了很長時間都沒想出來...

尤拉計畫第3題

problem 3 the prime factors of 13195 are 5,7,13 and 29.what is the largest prime factor of the number 600851475143.問題3 13195的質因數為5,7,13和 29。6008514751...