Skip to content

Armstrong number

Python sum of digit cubes

Flowchart (ISO 5807)

YesNoYesNoStartInput ns = 0t = nt > 0d = t mod 10s = s + d²dt = t div 10s = nOutput «Так»Output «Ні»EndFigure 1 — is_armstrong

Source code

Python
def is_armstrong(n):
    s = 0
    t = n
    while t > 0:
        d = t % 10
        s += d * d * d
        t //= 10
    if s == n:
        print("Так")
    else:
        print("Ні")

The editor opens with this code — change it and the chart redraws.

Language
Python
Constructs
sum of digit cubes
Topic
Loops
Formats
Word, Visio, draw.io, PDF, SVG

Related examples