Solution in perl Sajal Kayan 29th July, 2008 04:38 (UTC)

had done in c , basic in college n school to print the basic series,,, hv taken it a step further by adding 3 user inputs…

usage : ./fib.pl first-number second-number max-number

#!/usr/bin/perl
$a=$ARGV[0];
$b=$ARGV[1];
$c = $a + $b ;
print "$a $b ";
while ($c<$ARGV[2]) {
	print "$c ";
	$a = $b;
	$b = $c;
	$c = $a + $b ;
} 

For some strange reason unless i put an additional linebreak after each line, everything was getting condensed into one line.

Solution in perl Kirit Sælensminde 29th July, 2008 06:16 (UTC)
Sajal Kayan said

For some strange reason unless i put an additional linebreak after each line, everything was getting condensed into one line.

That's because of the [ ] operators in the solution — this is the same syntax as Mediawiki uses for hyperlinks so they get mistaken for that. If you put some whitespace inside them then everything should come out ok.


To join in the discussion you should register or log in