numnums 1.0.0 numnums: ^1.0.0 copied to clipboard
Helpful numeric types.
import 'dart:math';
import 'package:numnums/numnums.dart';
final _rand = Random();
_randomInt() => _rand.nextInt(2^32);
void main() {
final start = _randomInt();
final end = _randomInt();
var awesome = between(start, end);
if (start < end) {
print('$start $awesome $end');
} else {
print('$end $awesome $start');
}
final NaturalNumber n1 = NaturalNumber(_randomInt());
final NaturalNumber n2 = NaturalNumber(_randomInt());
print('$n1 $n2 nice features like GCD: ${n1.gcd(n2)} and LCM: ${n2.lcm(n1)}');
final Fraction n3 = Fraction(n1.val, n2.val);
print("$n3 can reduce to ${n3.reduce()} and flipped ${n3.reciprocal()}");
}