Armstrong Number Checker API: Identify Narcissistic Numbers

Armstrong numbers (also called narcissistic numbers) have a special property: they equal the sum of their own digits raised to the power of the number of digits. The Armstrong Number Checker API identifies these mathematical curiosities.

What is an Armstrong Number?

An Armstrong number (narcissistic number, pluperfect digital invariant) is a number that equals the sum of its own digits, each raised to the power of the number of digits.

Formula: For a number with n digits, it's Armstrong if: d1^n + d2^n + ... + dn^n = the number itself

Example: 153 is Armstrong because 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153

Armstrong Number Examples

Armstrong numbers by digit count:

1-digit (all are Armstrong)

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

3-digit

153, 370, 371, 407

4-digit

1634, 8208, 9474

Larger

54748, 92727, 93084, 548834...

Fun Fact: There are only 88 Armstrong numbers in base 10. The largest has 39 digits!

Using the Armstrong Number Checker API

TinyFn provides a simple endpoint to check Armstrong numbers:

API Request
GET https://api.tinyfn.io/v1/math/armstrong?number=153
Headers: X-API-Key: your-api-key
Response
{
  "number": 153,
  "is_armstrong": true,
  "digits": [1, 5, 3],
  "digit_count": 3,
  "calculation": "1^3 + 5^3 + 3^3",
  "digit_power_sum": 153,
  "breakdown": [
    {"digit": 1, "power": 3, "result": 1},
    {"digit": 5, "power": 3, "result": 125},
    {"digit": 3, "power": 3, "result": 27}
  ]
}

Parameters

Parameter Type Description
number integer The number to check (required, 0 to 10^15)
show_breakdown boolean Show detailed calculation (default: true)

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/math/armstrong?number=9474',
  { headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
if (data.is_armstrong) {
  console.log(`${data.number} is Armstrong: ${data.calculation} = ${data.digit_power_sum}`);
}

Python

import requests

# Find Armstrong numbers in a range
for n in range(100, 1000):
    response = requests.get(
        'https://api.tinyfn.io/v1/math/armstrong',
        headers={'X-API-Key': 'your-api-key'},
        params={'number': n, 'show_breakdown': False}
    )
    if response.json()['is_armstrong']:
        print(f"Found Armstrong number: {n}")

cURL

curl "https://api.tinyfn.io/v1/math/armstrong?number=153" \
  -H "X-API-Key: your-api-key"

Common Use Cases

  • Programming Interviews: Classic coding challenge question
  • Educational Tools: Teach number properties and loops
  • Math Puzzles: Generate interesting number sequences
  • Code Katas: Practice algorithm implementation
  • Number Theory: Explore digit-based number properties

Best Practices

  1. Know the count: There are only 88 Armstrong numbers in base 10
  2. Use for validation: Great for verifying your own implementations
  3. Understand the math: Digit count determines the exponent
  4. Handle edge cases: Single digits are always Armstrong by definition
  5. Explore other bases: Armstrong numbers exist in other number bases too

Try the Armstrong Number Checker API

Get your free API key and start checking Armstrong numbers.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key