Results 1 to 3 of 3

Thread: Fibonacci and the golden ratio

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    112

    Fibonacci and the golden ratio

    i ahve to write a program for uni in which i compute the fib numbers..i have to make a table..
    The table of data should stop if two consecutive rows give the same value for the golden ratio, or if the golden ratio becomes a negative value...
    i have to use FORTRAN 90 to write this..
    now the question is this: i obviously have to use arrays..now how do i know how big i should make the array? i dont know when the end pt will be reached..do i just use a big number? like 500?
    thanks in advance..

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well in fact you just need to hold the last two numbers, since fib(x)=fib(x-1)+fib(x-2)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    112
    so i would output all the info i have about the 2 current numbers, and then replace them? alright..thats a lot more ingenious than my "keep everything, waster memory" way.. thanks kedaman

Posting Permissions

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



Click Here to Expand Forum to Full Width