A simple RESTful API for classifying numbers based on various properties such as primality, Armstrong numbers, perfect numbers, and more.
- Check if a number is prime, Armstrong, or perfect.
- Determine if a number is even or odd.
- Compute the sum of digits of a number.
- Retrieve fun facts about numbers.
- Clone the repository:
git clone https://github.com/BerylCAtieno/numbers-classification-api.git cd numbers-classifier-api
- Install dependencies:
go mod tidy
Run the application locally with:
go run main.go
- URL:
/api/classify-number?number={number}
- Method:
GET
- Parameters:
number
(integer) - The number to classify.
- Response:
{ "number": 153, "isPrime": false, "isPerfect": false, "properties": ["armstrong", "odd"], "digitSum": 9, "funFact": "153 is an Armstrong number." }
You can test the API using curl
:
curl "https://numbers-classification-api-3b6h.onrender.com/api/classify-number?number=153"
Or using Postman by sending a GET
request to http://localhost:8080/api/classify-number?number=153
.
Author
Beryl Atieno
GitHub: BerylCAtieno