Learning Dart
This commit is contained in:
10
dart/armstrong-numbers/lib/armstrong_numbers.dart
Normal file
10
dart/armstrong-numbers/lib/armstrong_numbers.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'dart:math';
|
||||
|
||||
class ArmstrongNumbers {
|
||||
bool isArmstrongNumber(String number) {
|
||||
num total = 0;
|
||||
number.runes.forEach((r) => total += pow(int.parse(String.fromCharCode(r)), number.length));
|
||||
print("$number == $total");
|
||||
return num.parse(number) == total;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user