Sha256: 0edb916aa879754b8c933ff6121790ea7443c36accbae840004eadddf85aa53a
Contents?: true
Size: 678 Bytes
Versions: 37
Compression:
Stored size: 678 Bytes
Contents
import 'dart:math' show pow; class ArmstrongNumbers { /// The parameters and variables within the method that are set to final in order to prevent the accidentally modification of the value. /// As those variables are not needed to be changed. bool isArmstrongNumber(final int number) { final String numberAsString = number.toString(); final int numOfDigits = numberAsString.length; int sum = 0; for (int count = 0; count < numOfDigits; count++) { final String digitAsString = numberAsString.substring(count, count + 1); final int digit = int.parse(digitAsString); sum += pow(digit, numOfDigits); } return number == sum; } }
Version data entries
37 entries across 37 versions & 1 rubygems