Closed Thread
Results 1 to 2 of 2

Thread: incredibly large integers (Fibonacci sequence)

  1. #1
    Join Date
    May 2008
    Posts
    27
    Rep Power
    0

    incredibly large integers (Fibonacci sequence)

    Out of boredom, I created a simple script that would write out the Fibonacci sequence.

    There are no errors, just a nuisance.

    The code:
    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);
    }
    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:
    .
    .
    .
     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
    Now, can I make it display the integer, rather than just saying 'inf'?
    Programming is an art form. Everyone can program, but few can do it right.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0

    Re: incredibly large integers (Fibonacci sequence)

    look into biginit:

    bigint - perldoc.perl.org

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Fibonacci difficult question
    By skd in forum C and C++
    Replies: 1
    Last Post: 04-24-2011, 12:34 AM
  2. Fibonacci with no recursion for fun
    By HAL 9000 in forum C and C++
    Replies: 14
    Last Post: 11-28-2010, 06:53 AM
  3. Beginner problem: Fibonacci sequence
    By TheGame in forum Python
    Replies: 4
    Last Post: 09-23-2010, 04:21 PM
  4. Young–Fibonacci lattice
    By Tungsten Tide in forum C and C++
    Replies: 1
    Last Post: 03-19-2010, 10:20 AM
  5. Fibonacci Sequence
    By Termana in forum CSharp Tutorials
    Replies: 5
    Last Post: 07-27-2009, 12:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts