![]() ![]() So I google around for the solution and found a Yahoo! Answers page which says that the sum of all primes below 2 million is 142,913,828,922. Is the sum larger than that? It’s already been around 4 minutes and I’m impatient. Then found that the SQL Sever BigInt is actually a 64 bit int, so guess even the. So, I quickly google around and see that BigInt is for arbitrarily large integers. Now, I start getting worried about the range of BigInt and whether the result would overflow. I check the fsi.exe process, and it’s maxing out one of the cores completely and taking around 50M. I switch back to the F# interactive window and see that it’s still happily calculating. ![]() So, ask it to calculate the sum of all primes below 2 million and left it for a minute. ![]() After all, it’s my computer doing the job right? □ The last one took a bit of time, but that didn’t really concern me much. Let rec add_prime (n:bigint) (acc:bigint) =ĭid a quick check for the sum of primes below 10, 20, 200, 200. Let sum_of_primes_below (limit :bigint ) = let rec add_prime (n :bigint ) (acc :bigint ) = let next = next_prime n ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |