sum prime numbers
- mvn archetype:generate -DgroupId=com.example -DartifactId=sum-prime-numbers -DinteractiveMode=false
- copy spring boot REST prototype app https://github.com/spring-guides/gs-rest-service
- create one REST endpoint and test for it
- make a service class responsible for performing calculations
- implement the prime numbers finding algorithm
- add one more REST endpoint
- extend the solution to support the requirement of ten million limit
- evaluate performance, optimize algorithm, current result 4s for 1-1m, 5min for 1-10m
- make a code to generate and load a pre-calculated table
- generate it
I stop the development here. It took about 3.5 hours and looks good to me.
git clone https://github.com/abalanonline/sum-prime-numbers.git
mvn clean install
java -jar target/sum-prime-numbers-1.0-SNAPSHOT.jar
curl -w '\nTime: %{time_total}s\n' http://localhost:8080/sum-primes/from/1/till/10000000
chromium http://localhost:8080/sum-primes/from/1/till/10000000