Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: challenge: OEIS A073015 serie

by danaj (Friar)
on Dec 18, 2015 at 12:44 UTC ( #1150692=note: print w/replies, xml ) Need Help??


in reply to challenge: OEIS A073015 serie

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.

Replies are listed 'Best First'.
Re^2: challenge: OEIS A073015 serie
by Laurent_R (Canon) on Dec 18, 2015 at 23:11 UTC
    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.
Re^2: challenge: OEIS A073015 serie
by Anonymous Monk on Dec 18, 2015 at 17:10 UTC

    Trolling season!

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1150692]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-01-25 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (66 votes). Check out past polls.

    Notices?