This is my first time posting here. I don't know how much it could be considered obfuscation, but this is my first attempt. It's simple. It's the answer to the problem that is on everyone's mind. If we start with two immortal rabbits, and they have two children every
month year, how many rabbits will we have after nth month. The answer, of coarse, is the Fibonacci sequence :). This script takes one command line argument. Plug in a number for the nth month and it should print the sequence up to that month :). Sorry for the simplicity, and the bad ASCII art (I had to write it out without help from an ASCII art generator).
#!/usr/bin/perl -w
;;;;; ;;;;;
;;;;;;;;; ;;;;;;;;;;;;
use strict; fib($ARGV[0]||42);
sub fib { my @fibs=(1,1,0);;
for(my $n=2;$n <$_[0];$n++) {
$fibs[$n]=$fibs [$n-1]+$fibs
[$n-2]; }my $sequence
=@fibs; print
"{"; for(my
$x=0; $x<=
$sequence;
$x++)
{ if($x ==$sequence) { print
". . .}"; }else { print $fibs[$x];
print ",";} }print "\n";}
; ; ;
; ; ;
;;;;;;;;;;;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.