Discipulus has asked for the wisdom of the Perl Monks concerning the following question:

This born casually when I was playing with another challenge.. and I'll be glad to see other's solutions.

The serie is described in OEIS A073015 and is formed by numbers:
3, 4, 9, 64, 3969, 15745024, 247905749270529, 614572605213818940 +04129398784, ...

Here the constraints of the challange:
Comments about the serie are welcome as solutions.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re: challenge: OEIS A073015 serie
by Discipulus (Canon) on Dec 18, 2015 at 12:25 UTC
    Here is my 35 char solution:
    perl -E "say$_=3;/I/?die:say$_*=$_ while--$_" #35
    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      On my system, ∞ is inf, so I needed to lowercase the I.

      Here's my shorter version:

      # 1 2 3 # 12345678901234567890123456789012345 perl -E 'say$_=3;/i/?die:say$_*=$_ while--$_' # old perl -E 'say$_=3;say$_*=--$_ while$_&&!/i/' # new
      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

        Playing with your proposal a bit leads to

        $_=3;say,$_*=--$_ while!/i/
Re: challenge: OEIS A073015 serie
by danaj (Friar) on Dec 18, 2015 at 12:44 UTC

    Without using a bigint module, you can't generate much of the series. I suspect correct Perl 6 solutions would be really easy.

    use bigint; my $f=3; for (1..12) { $f = ($f-1)**2 if $_>1; say $f } # Faster: replace bigint with Math::GMP qw/:constant/;

    I admit I find code golf to be tiresome, and prefer readable and efficient solutions.

      I suspect correct Perl 6 solutions would be really easy.
      Yes, indeed, really easy in Perl 6, except that you can't seem to get to infinity. ;-) So there is a need for some other way of stopping the calculation than just looking for /inf/ or the like.

      In fact, it is so easy that I just needed to copy and paste your code and run it with Perl 6/Rakudo:

      $ perl6 -e 'my $f=3; for (1..16) { $f = ($f-1)**2 if $_>1; say $f }' 3 4 9 64 3969 15745024 247905749270529 61457260521381894004129398784 ...
      The full output for those interested with big nums (adding an extra newline between the numbers for a better clarity of output) is given below: The last number above has more than 7300 digits. The whole one-liner script executes in less than 1 second, but it starts to show a noticeable slow down when getting above 16.

      Trolling season!

      perl -E 'say(eval),$,.=$#$,$,x=eval,redo,for$,="+3"'