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.

Results 1 to 4 of 4

Thread: Fibonacci numbers? How to define these numbers in some interval (diapazone)

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Fibonacci numbers? How to define these numbers in some interval (diapazone)

    [

    --- 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


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,848
    My Mood
    Mellow
    Thanks
    239
    Thanked 721 Times in 707 Posts

    Default Re: Fibonacci numbers? How to define these numbers in some interval (diapazone)

    Please, please, please ask a reasonably understandable question. Show some code - even a skeleton of what you're trying to do.

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Fibonacci numbers? How to define these numbers in some interval (diapazone)

    Quote Originally Posted by GregBrannon View Post
    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].

  4. #4
    Member mjr's Avatar
    Join Date
    Jan 2012
    Location
    127.0.0.1
    Posts
    36
    My Mood
    Fine
    Thanks
    8
    Thanked 2 Times in 1 Post

    Default Re: Fibonacci numbers? How to define these numbers in some interval (diapazone)

    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...

Similar Threads

  1. Replies: 4
    Last Post: February 10th, 2013, 10:58 PM
  2. Concatenation of numbers
    By Ademola in forum Member Introductions
    Replies: 2
    Last Post: November 9th, 2011, 08:50 AM
  3. [METHOD] How: Count how many prime numbers there is between two numbers!
    By Secret20 in forum Object Oriented Programming
    Replies: 4
    Last Post: October 18th, 2011, 02:30 PM
  4. [SOLVED] Scale Numbers from 0.0f to 1.0f
    By techwiz24 in forum Java Theory & Questions
    Replies: 1
    Last Post: September 23rd, 2011, 09:50 PM
  5. Help with sorting numbers
    By planktonx in forum Collections and Generics
    Replies: 2
    Last Post: October 5th, 2010, 08:01 AM