Search Search for: Software DevelopmentAll Forums

Java sequence generator

 Boe
Account Disabled with 16 posts.

Join Date: Sep 2004
03-Nov-2004, 10:50 AM #1
Java sequence generator
Hello everyone. I am not trying to get someone to do my homework for me but I am stuck on a program. I dont know if you are familiar with the "fibonacci generator". The first two nubers of the sequence are 1. The third number it always the sum of the prior two numbers. the third number is the sum of 1 and 1. third number = 2. the fourth number is the some of the 2nd and 3rd digit. the seguence reads as follows... 1,1,2,3,5,8,13,21.... so on. anyways, I need to write a generator to figure out this sequence so when a user enters a digit number, like the 16 fib number, then generator will tell the user what the actual number is.
Member with 6,650 posts.

Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
04-Nov-2004, 03:14 AM #2
Hi Boe,

Quote:
 // Fibonacci generator // fill an array of 500 fibonacci numbers // int a[] = new int[500]; a[0] = 1; a[1] = 1; for (int i = 2; i < 500; i++) { a[i] = a[i-1] + a[i-2]; } // Display the Fibonacci number int userValue = value entered by the user System.out.println("Fibonacci number " + userValue + " = " + a[userValue - 1]);
 Boe
Account Disabled with 16 posts.

Join Date: Sep 2004
04-Nov-2004, 12:31 PM #3
Alright thanks. I did finally figure it out yesterday, but your help is most appreciated.
 techguy.org/291937
As Seen On

WELCOME TO TECH SUPPORT GUY!

If you're not already familiar with forums, watch our Welcome Guide to get started.

Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your computer problem!

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)