nth_root_recurrence_constant.pl 456 B

1234567891011121314151617181920
  1. #!/usr/bin/perl
  2. # Author: Daniel "Trizen" Șuteu
  3. # License: GPLv3
  4. # Date: 10 May 2016
  5. # Website: https://github.com/trizen
  6. # Compute the nth root recurrence constant (n * (n * (n * (n * ...)^(1/4))^(1/3))^(1/2))
  7. # See also: https://en.wikipedia.org/wiki/Somos%27_quadratic_recurrence_constant
  8. use 5.010;
  9. use strict;
  10. sub root_const {
  11. my ($n, $limit) = @_;
  12. $limit > 0 ? ($n * root_const($n+1, $limit-1))**(1/$n) : 1;
  13. }
  14. say root_const(1, 30000);