Skip to content

CrowCpp sample project providing prime-related endpoints

Notifications You must be signed in to change notification settings

ui-1/crow_prime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

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.

Requirements


Endpoints

Three endpoints are provided and can be accessed via HTTP GET requests:

Primality Test (/is_prime/<number>)

Check if a number is prime.

Example

% curl localhost:8080/is_prime/7
true
% curl localhost:8080/is_prime/12
false

Euler's Totient Function (/totient/<number>)

Calculate the number of integers less than or equal to a given integer that are coprime to it.

Example

% curl localhost:8080/totient/21
12
% curl localhost:8080/totient/999
648

Prime Factorization (/factorization/<number>)

Find the prime factors of a number.

Example

% curl localhost:8080/factorization/12
[2,2,3]
% curl localhost:8080/factorization/43912
[2,2,2,11,499]

About

CrowCpp sample project providing prime-related endpoints

Topics

Resources

Stars

Watchers

Forks