[
--- Update ---
This task is only the sub-task of more general task that should be done knowing the correctly of this numbers in this range
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
[
--- Update ---
This task is only the sub-task of more general task that should be done knowing the correctly of this numbers in this range
Please, please, please ask a reasonably understandable question. Show some code - even a skeleton of what you're trying to do.
Honestly, i do not know where the main my question disppepered from this newly created topic. I hope you are not moderator, as this my sentence only was addition to the question itself. and I re-edited it-so maybe this is the reason of its absence. so I rewrite it-to be understandable for you.
I had a task to do something with fibonacci numbers in the range from int M to int N. I defined the function int fibon(k)
{ if (k=0) return 0;
else if (k=1) return 1;
else return fibon(k-1)+fibon(k-2);
} Maybe this method is not very correct relating to the braces according to the http://en.literateprograms.org/Fibon...mbers_(Java)--
<<Fibonacci.java>>=
public class Fibonacci {
public static int fib(int n) {
if (n < 2) {
return n;
}
else {
return fib(n-1)+fib(n-2);
}
}
test main
} But I ask how to find this fibonacci numbers at the range of [M;N]; Should i use loop FOR from M to N and check if M<fibon(i)<N? It is very difficult as I need to equal fibo(i) with the first and in the last case with the last fibonacci number-and it is difficult to do it with simole LOOP. So I need define what is i1 and i2 that begin and end the fibonacci set at this range from M to N. Or i simply choose some approximate range of i (for (i=l; i<h; i++) and use the extensive loop for the fibon (i) and only check it in FOR loop for the M<fibon(i)&&fibon(i)<N. As I said the main task is for example do this fibonacci numbers at this range is dividable on 2. So it is not such easy. But at first I need to define this specific numbers at this range.
So the question is veri easy: to find the fisrt and the last fibonacci n. at the range[M;N].
Use Binet's formula, and the range of the numbers, if I understand you correctly.
Let's say your range is from "position" 2 to 5.
You would use a for loop that starts at 2, and go from there.
So at position 2, your answer should be 1
At 3 it should be 2
At 4 it should be 3
At 5 it should be 5
etc...