Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

Java sequence generator


(!)

Boe's Avatar
Boe Boe is offline
Account Disabled with 16 posts.
THREAD STARTER
 
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.
Chicon's Avatar
Computer Specs
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's Avatar
Boe Boe is offline
Account Disabled with 16 posts.
THREAD STARTER
 
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.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

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


(clock)
THIS THREAD HAS EXPIRED.
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)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑