Armstrong Number

Practice this coding question on Coding Gurukul.

Problem statement

A puzzle kiosk marks a three-digit locker code as special when the cubes of its individual digits add back up to the original code. Your task Determine whether n is an Armstrong number under the three-digit cube rule. Important details For decimal digits a, b, and c, compare a cubed plus b cubed plus c cubed with n. Each digit is cubed separately; do not cube the sum of the digits. A zero digit contributes zero. All inputs contain exactly three digits, so the exponent is always three. Return a Boolean classification instead of listing the component cubes or searching for other matching codes. Worked example For 153, the calculation is 1 cubed + 5 cubed + 3 cubed = 1 + 125 + 27 = 153, so print true.

Input format

One integer n.

Output format

Print true if n satisfies the rule, otherwise false.

Constraints

100 <= n <= 999.

Sample input

153

Sample output

true

Sign in to run or submit a solution in C++, Java or Python.