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

Challenge: Simple algorithm for continuing series of integers

by moritz (Cardinal)
on Oct 19, 2008 at 19:26 UTC ( [id://718080]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @even   = 0, 2, 4 ... { $_ + 2};
    my @powers = 1, 2, 4 ... { $_ * 2 };
    my @fib    = 1, 1, 2 ... { $^a + $^b};
    
  2. or download this
    my @ints   = 1, 2, 3, 4 ... *;
    my @even   = 0, 2, 4, 6 ... *;
    my @powers = 1, 2, 4, 8 ... *;
    
  3. or download this
    1, 3, 5 ... *        # odd numbers
    1, 2, 4 ... *        # powers of 2
    
  4. or download this
    sub series(@items, $recursion_level = 2) {
        return if $recursion_level < 0;
    ...
        # give up
        return;
    }
    
  5. or download this
    use List::MoreUtils qw(all);
    sub series {
    ...
        return;
    }
    
  6. or download this
    #!/usr/bin/perl
    use strict;
    ...
        $result = 'undef' unless defined $result;
        is $result, $expected, "seq " . join(', ', @{$t->[0]});
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found