Go to Top

Sunday 16 October 2011

To find non-fibonacci numbers

Question 62 : Write a program in Java to find and print the non-fibonacci numbers up to a limit entered by the user.

Java Program :

class non_fibonacci
{
 static void check(int n)
 {
    int a=2,b=3,i,j;
    System.out.print("The non-fibonacci numbers are : ");
    loop1: for(;;)
     {
         i=a+b;
         for(j=b+1;j<i;j++)
         {
             if(j>n)
            break loop1;
            System.out.print(j+" ");
        }
         a=b;
         b=i;
        }
    }
}

9 comments:

  1. That's a modified share button. Upgraded one.

    ReplyDelete
  2. thanks 4 d program

    ReplyDelete
  3. JUSR THE PERFECT ONE REQUIRED

    ReplyDelete
    Replies
    1. It's not perfect one main class is missing

      Delete
  4. MAin method missing in above program.kindly provide the correct one.

    ReplyDelete
  5. Give an input example and output

    ReplyDelete
  6. Do it easily... We can't get u

    ReplyDelete

ShareThis