Skip to content

Latest commit

 

History

History
64 lines (37 loc) · 1.7 KB

README.md

File metadata and controls

64 lines (37 loc) · 1.7 KB

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