Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Armstrong Number Program

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Armstrong Number Program. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

A validation utility in Capgemini Engineering must identify whether a non-negative integer has the Armstrong property. Write a function that returns True when the number equals the sum of its digits, with every digit raised to the total number of digits, and returns False otherwise.

Formal Specification

Given an integer number, return a Boolean. For a number with k decimal digits d1, d2, ..., dk, it is an Armstrong number if:

number = d1^k + d2^k + ... + dk^k

Treat 0 as a one-digit Armstrong number because 0^1 = 0. Do not convert the number to a string in the primary solution. Extract digits using arithmetic operations such as modulo and integer division.

Constraints

  • 0 <= number <= 10^9
  • The input is a single non-negative integer.
  • Return exactly one Boolean value.

Function Signature

def is_armstrong(number):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output