Out of boredom, I created a simple script that would write out the Fibonacci sequence.
There are no errors, just a nuisance.
The code:
Notice how I put the number of cycles for the loop to run to at 1476. I'm not sure why, but when I put it at 1480, I get something like this:Code:sub allnum { open LOG, ">", "Fibbonacci Sequence" || die $!; my $v1 = 1; my $v2 = 2; my $v3 = 3; my $cycles; print "1, 1\n 1, 2\n 2,\n"; print LOG "1, 1\n 1, 2\n 2, 3\n"; for($cycles = 4; $cycles < 1476; $cycles++) { print " $v3,"; print LOG " $v3, $cycles\n"; $v1 = $v2; $v2 = $v3; $v3 = $v1 + $v2; } close(LOG); }
Now, can I make it display the integer, rather than just saying 'inf'?Code:. . . 2.78208813961179e+306, 1468 4.50151316958984e+306, 1469 7.28360130920163e+306, 1470 1.17851144787915e+307, 1471 1.90687157879931e+307, 1472 3.08538302667846e+307, 1473 4.99225460547777e+307, 1474 8.07763763215622e+307, 1475 1.3069892237634e+308, 1476 inf, 1477 inf, 1478 inf, 1479
Programming is an art form. Everyone can program, but few can do it right.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks