# I also present you with this, an ever so slightly improved version: func isArmstrongNumber(n: int): bool = var total = 0 exponent = 1 cache: array[0..9, int] let digits = n.float32.log10.ceil.int while exponent < n: let d = (n div exponent) mod 10 if d != 0 and cache[d] == 0: cache[d] = d ^ digits total += cache[d] exponent = 10 n == total