Skip to content

Find the sum of all the primes below 2 million

Notifications You must be signed in to change notification settings

mymai91/prime_demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use Ruby programing language to solve

Basic Logic

Please write a script or program to solve the following

Problem 1

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

Find the sum of all the primes below 2 million.

Problem 2

Which prime, below one million, can be written as the sum of the most consecutive primes?

Solve

At prime folder:

Run test case

rspec spec/prime_spec.rb

screen shot 2016-06-08 at 10 23 14 pm

Check output for problem 1

Find the sum of all the primes below 2 million

ruby output/sum_of_all_primes.rb

screen shot 2016-06-08 at 10 25 07 pm

Check the time find the sum of all the primes below 2 million

time ruby output/sum_of_all_primes.rb

screen shot 2016-06-08 at 10 26 34 pm

Check output for problem 2

Find prime, below one million, can be written as the sum of the most consecutive primes

ruby output/sum_of_most_consecutive_primes.rb

screen shot 2016-06-08 at 10 32 39 pm

Check the time find prime, below one million, can be written as the sum of the most consecutive primes

time ruby output/sum_of_most_consecutive_primes.rb

screen shot 2016-06-08 at 10 33 38 pm

About

Find the sum of all the primes below 2 million

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages