fork download
  1. #!/usr/bin/perl
  2. use 5.016;
  3. use warnings;
  4. no warnings qw(recursion);
  5. use List::Util qw(reduce);
  6.  
  7. my @memo = (0, undef, undef, 0);
  8.  
  9. sub f { $memo[$_[0]] //= 1 + f($_[0] % 2 ? ($_[0] + 1) * 3 : $_[0] / 2) }
  10.  
  11. say reduce{ f($b) > f($a) ? $b : $a } (1 .. 10000);
  12.  
Success #stdin #stdout 0.29s 135616KB
stdin
Standard input is empty
stdout
7421