Skip to content

BerylCAtieno/numbers-classification-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Numbers Classifier API

A simple RESTful API for classifying numbers based on various properties such as primality, Armstrong numbers, perfect numbers, and more.

Features

  • 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.

Table of Contents

Installation

  1. Clone the repository:
    git clone https://github.com/BerylCAtieno/numbers-classification-api.git
    cd numbers-classifier-api
  2. Install dependencies:
    go mod tidy

Running the API

Using Go

Run the application locally with:

go run main.go

API Endpoints

Classify a Number

  • 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."
    }

Testing the API

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

About

A simple Go-based API that classifies numbers based on various properties (prime, perfect, Armstrong, even/odd) and provides fun facts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published