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

Version Path
trackler-2.2.1.159 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.158 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.157 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.156 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.155 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.154 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.153 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.152 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.151 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.150 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.149 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.148 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.147 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.146 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.145 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.144 tracks/dart/exercises/armstrong-numbers/lib/example.dart
trackler-2.2.1.143 tracks/dart/exercises/armstrong-numbers/lib/example.dart