A tiny and easy to understand CrowCpp sample project that provides endpoints for checking if a number is prime,
calculating Euler's totient function, and finding prime factorizations. It correctly handles large numbers (up to the
maximum value of int64_t
), validates inputs, and returns appropriate HTTP status codes. 100% test coverage using
Catch2 and few external dependencies.
Three endpoints are provided and can be accessed via HTTP GET requests:
Check if a number is prime.
% curl localhost:8080/is_prime/7
true
% curl localhost:8080/is_prime/12
false
Calculate the number of integers less than or equal to a given integer that are coprime to it.
% curl localhost:8080/totient/21
12
% curl localhost:8080/totient/999
648
Find the prime factors of a number.
% curl localhost:8080/factorization/12
[2,2,3]
% curl localhost:8080/factorization/43912
[2,2,2,11,499]