Rob Spoor wrote:There are three very clear errors in your code:
1) You always set the position argument to 10, so no matter what Fibonacci number you want, you would always get the same value (for position 10).
2) Your loop body always does the exact same thing. It doesn't use the loop counter, but always does the same thing, regardless of the input.
3) You always return 0.
You need to step away from a computer, and write down on paper how you would do this first.
Piet Souris wrote:I gave an example of how to convert a two-digit array into a String, with the question how to proceed if you did not know the length of the array upfront. How about using some loop?
Campbell Ritchie wrote:MB: welcome to the Ranch
How far have you got?
Piet Souris wrote:@Kaid,
if you have an array, say a{0, 1}, then "" + a[1] + a[0] would deliver the String "10". Your array might have a length that is not known beforehand, how would you tackle that problem?
Edit: assuming your problem is converting your array to a String....
Stephan van Hulst wrote:
Kaid Daik wrote:also can someone tell me how to directly reply to people.
Kaid, either quote the relevant part of the post that you are replying to, or just name them in your reply, as I demonstrated in this reply.