1. the reason for me doing it recursively is because its an exercise in recursion.
2. after looking at the sequence of numbers i determined that 1 was the base case.
and if the position of the nth number was even it would multiply the previos number by 3 and subtract 1 if the position of the nth number was odd it would multiply by 3 and add 1.
the assignment was simply to create the method as i have done ( i believe).
in addition to this i wanted to write the program to see the function work....that im not sure how to do it.
the list im referring to is the list of numbers 1, 4 , 11, 34, 101.
I am simply tryin to create a recursive program to find the 6th integer in this list.
Thanks
Then I'd say you want to pass the function
n , not
nthfibo .
What kind of List are you going to use? It's a matter of personal preference, but I like Vector. You could make this your function:
public static void fibo(Vector <Integer> numbers, int n)
If you're going to have a Vector, you'll need to pass
fibo the Vector each recursive call, so you might as well have it be a
void function. So if you passed it an empty Vector, the following call:
could result in
numbers holding {1, 4, 11, 34, 101, 304}. Is that what you're looking for? I'd rename the function though.
I am simply trying to create a recursive program to find the 6th integer in this list.
So you do want the whole List, right, not just the 6th element?