Sum Of Primes.
Difficulty: (2/5)Write a program that will take an integer as a command line argument and print the sum of all primes less than that number. For example:
% java SumPrimes 10would sum the primes below 10:
2 + 3 + 5 + 7 = 17To test your program, calculate the sum of all primes below a million:
Hints: Use the Sieve of Eratosthenes. Also, realize that the sum of all primes below a million is too big to fit in an int.
CS1 Deadline: 11/8/2013
Use: handin cs1113 extra2 SumPrimes.java
No comments:
Post a Comment