This is a simple API built with Next.js that classifies numbers and provides interesting mathematical properties along with a fun fact.
- Clone the repository:
git clone https://github.com/abijay440/classify-number.git
cd your-repo
- Install dependencies:
npm install
- Run the development server:
npm run dev
Endpoint:
GET /api/classify-number?number=371
Response Format:
- Success Response (200 OK)
{
"number": 371,
"is_prime": false,
"is_perfect": false,
"properties": ["armstrong", "odd"],
"digit_sum": 11,
"fun_fact": "371 is an Armstrong number because 3^3 + 7^3 + 1^3 = 371"
}
- Error Response (400 Bad Request)
{
"number": "alphabet",
"error": true
}
Example Usage:
curl http://localhost:3000/api/classify-number?number=371
Deploy the API to a platform of your choice (e.g., Vercel, Heroku).
Example (Vercel):
- Install Vercel
npm install -g vercel
- Deploy the project:
vercel
[Hire Node.js Developers] https://hng.tech/hire/nodejs-developers