Results 1 to 4 of 4
Thread: Help with Array
 10092011, 10:20 PM #1Member
 Join Date
 Oct 2011
 Posts
 3
 Rep Power
 0
Help with Array
I'm working on a project in my Java 2 course. I have the first two parts down but the final part has me stumped. I seriously think I am just over thinking this.
I am being asked to create a class that handles large array values (we have created a class that generates fibonacci numbers and stores them in an array) for example the 100th fibonacci number generated and stored in the array is
354,224,848,179,261,915,075 and represent it by four array elements:
 arrF[n] = 261915075
 arrF[n+1] = 224848179
 arrF[n+2] = 354
 arrF[n+3] = 0
and do the same for any other large number generated respectively.
I am not looking for an answer as I want to figure this out myself but any suggestions or hints to help put me on the right track would be apprectiated because as of now I am completely stumped! Thanks in advance for any assistance.
 10092011, 11:17 PM #2Moderator
 Join Date
 Feb 2009
 Location
 New Zealand
 Posts
 4,704
 Rep Power
 13
Re: Help with Array
I'm not completely clear what you are asking. Have you already written the class that generates these Fib values as 4 part array values? Or does your existing code use some other data type?

If you use BigInteger to generate the fibonacci sequence with f(n+1)=f(n)+f(n1) then the four array elements can be obtained by dividing the Fib value by the appropriate powers of 10.
On the other hand you could create arrF directly by calculating the next four values based on the previous eight. The important step would be to figure out how to add two integer values like:
Java Code:a*10^0 + b*10^10 + c*10^20 + d*10^30 c*10^0 + d*10^10 + e*10^20 + f*10^30
 10102011, 12:51 AM #3Member
 Join Date
 Oct 2011
 Posts
 3
 Rep Power
 0
Re: Help with Array
Yes, I have written the class that generates the fibonacci numbers. In this case I am writing a second class (FibonacciLarge) that will simply utilize the code from my original class to generate the numbers. We limited the first class to the first 25 fib numbers. This time we will accept values up to f100 then take the 100th fib # and divide it up into 4 seperate array elements.
Thanks for the assistance!
 10102011, 12:51 AM #4Member
 Join Date
 Oct 2011
 Posts
 3
 Rep Power
 0
Re: Help with Array
Yes, I have written the class that generates the fibonacci numbers. In this case I am writing a second class (FibonacciLarge) that will simply utilize the code from my original class to generate the numbers. We limited the first class to the first 25 fib numbers. This time we will accept values up to f100 then take the 100th fib # and divide it up into 4 seperate array elements.
Thanks for the assistance!
Similar Threads

Display Array on another class after extracting from txt file and into array problem
By jonathan920 in forum NetBeansReplies: 0Last Post: 05122011, 07:04 PM 
Variable of an object in an array compared to an element of another array?
By asmodean in forum New To JavaReplies: 23Last Post: 09072010, 08:12 PM 
Trying to make an array list // inserting an element to middle of array
By javanew in forum New To JavaReplies: 2Last Post: 09062010, 01:03 AM 
Convert Char Array to String Array
By Mayur in forum New To JavaReplies: 8Last Post: 10122009, 11:41 AM 
How to add an integer to a array element and the store that backinto an array.
By Hannguoi in forum New To JavaReplies: 1Last Post: 03312009, 06:40 AM
Bookmarks