Problem 3: Sum of Primes
Problem 3: Sum of Primes
What is the sum of a range of primes, specified by order (inclusive)?
Inputs: Start and end numbers, as integers
Outputs: Sum of primes
Example:
Tips:
Extension:
Find the product of the primes. Watch for integer overflows!
Inputs: Start and end numbers, as integers
Outputs: Sum of primes
Example:
- Code:
Start: 1st
End: 5th
Sum: 2 + 3 + 5 + 7 + 11 = 28
- Code:
Start: 3rd
End: 6th
Sum: 5 + 7 + 11 + 13 = 36
- Code:
Start: 125th
End: 3576th
Sum: 691 + 701 + ... + 33377 + 33391 = 56134516
Tips:
- Make sure you did Problem 2 properly.
Extension:
Find the product of the primes. Watch for integer overflows!
Elusive- Newbie
- Posts : 10
Join date : 2011-06-04
Permissions in this forum:
You cannot reply to topics in this forum
|
|