- or download this
32:my $only_unique = 1; # eliminate numbers that are just a reorder
+ing of digits
...
44: ## hash to remove duplicates. we also must sort the value it po
+ints to.
45: if ($only_unique) {$n = sortHiLow($n);
46: $nn = sortHiLow($nn);}
- or download this
100:## runs kaprekar routine on a number until it either cycles or con
+verges:
101:sub kRoutine {
- or download this
72:## given a number, performs one iteration of the kaprekar routine a
+nd returns num
73:sub gotoNext {
...
78:
79: return $new_num;
80:}
- or download this
sub gotoNext {
my $n = shift;
sprintf '%0*d', $digits, sortHiLow( $n ) - sortLowHi( $n );
}