← All examples

Armstrong number

Python Loops

sum of digit cubes

Flowchart (ISO 5807)

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

Source code

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("Ні")