Giter VIP home page Giter VIP logo

Comments (19)

milan604 avatar milan604 commented on July 30, 2024

package finonaccichecker;

/**
*

  • @author m-lan
    */
    public class FinonacciChecker {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      System.out.println("Checking Fibonacci Number...");
      System.out.println("1 true:" + isFibonacciNumber(1));
      System.out.println("2 true:" + isFibonacciNumber(2));
      System.out.println("3 true:" + isFibonacciNumber(3));
      System.out.println("4 false:" + isFibonacciNumber(4));
      System.out.println("5 true:" + isFibonacciNumber(5));
      System.out.println("11 false:" + isFibonacciNumber(11));
      System.out.println("21 true:" + isFibonacciNumber(21));
      }

    static boolean isFibonacciNumber(int n) {
    return isPerfectSquare(5 * n * n + 4) || isPerfectSquare(5 * n * n - 4);
    }
    static boolean isPerfectSquare(int n) {
    int Sq = (int) Math.sqrt(n);
    return (Sq * Sq == n);
    }
    }

screenshot from 2017-08-13 14-44-15

from java.

jagdish4249 avatar jagdish4249 commented on July 30, 2024

package fibcheck;

import java.util.Scanner;

/**
*

  • @author Jagdish Duwal
    */
    public class FibCheck {

    /**

    • @param args the command line arguments
      */

    static boolean isFibonacciNumber(int x ){

     int a = 0, b = 1,c,pos=0;
    

    if(x<a) {
    System.out.println("invalid input");

    }else{

     while(x>=a){
          c= a+b;
                 a=b;
                 b=c;
                 if(x==a){
                     pos++;
                     break;
                 }
    
     }
    

}
if(pos > 0 ) return true;
else return false;

}




public static void main(String[] args) {
    int x;

     System.out.println("1 true:" + isFibonacciNumber(1));
    System.out.println("2 true:" + isFibonacciNumber(2));
    System.out.println("3 true:" + isFibonacciNumber(3));
    System.out.println("4 false:" + isFibonacciNumber(4));
    System.out.println("5 true:" + isFibonacciNumber(5));
    System.out.println("11 false:" + isFibonacciNumber(11));
    System.out.println("21 true:" + isFibonacciNumber(21));

}

}
capture

from java.

karmi214 avatar karmi214 commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package fibonaciinumberchecker;

/**
*

  • @author Anish
    */
    public class FibonaciiNumberChecker {

    static boolean isFibonacciNumber(int n) {
    int f1 = 0, f2 = 1;
    boolean f = false;
    while (n >= f1) {
    if (n == f1) {
    f = true;
    break;
    }
    f2 = f1 + f2;
    f1 = f2 - f1;
    }
    return f;
    }

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      System.out.println("1 true:" + isFibonacciNumber(1));
      System.out.println("2 true:" + isFibonacciNumber(2));
      System.out.println("3 true:" + isFibonacciNumber(3));
      System.out.println("4 false:" + isFibonacciNumber(4));
      System.out.println("5 true:" + isFibonacciNumber(5));
      System.out.println("11 false:" + isFibonacciNumber(11));
      System.out.println("21 true:" + isFibonacciNumber(21));
      }

}
f

from java.

RakenShahi avatar RakenShahi commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package fibonaccicheck;

/**
*

  • @author DELL
    */
    public class FibonacciCheck {

    static boolean iPS(int x) {
    int s = (int) Math.sqrt(x);
    return (s * s == x);
    }

    static boolean isFibonacciNumber(int n) {
    return iPS(5 * n * n + 4)
    || iPS(5 * n * n - 4);
    }

    public static void main(String[] args) {
    System.out.println("1 true:" + isFibonacciNumber(1));
    System.out.println("2 true:" + isFibonacciNumber(2));
    System.out.println("3 true:" + isFibonacciNumber(3));
    System.out.println("4 false:" + isFibonacciNumber(4));
    System.out.println("5 true:" + isFibonacciNumber(5));
    System.out.println("11 false:" + isFibonacciNumber(11));
    System.out.println("21 true:" + isFibonacciNumber(21));
    }
    }

OUTPUT
fibonaccicheck

from java.

SusanCB avatar SusanCB commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package task10.pkg2;

/**
*

  • @author nissus
    */
    public class Task102 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {

    System.out.println("1 true:" + isFibonacciNumber(1));
    System.out.println("2 true:" + isFibonacciNumber(2));
    System.out.println("3 true:" + isFibonacciNumber(3));
    System.out.println("4 false:" + isFibonacciNumber(4));
    System.out.println("5 true:" + isFibonacciNumber(5));
    System.out.println("11 false:" + isFibonacciNumber(11));
    System.out.println("21 true:" + isFibonacciNumber(21));
    }
    static boolean isFibonacciNumber(int n){
    int a=0,b=1,c=0,count=0;
    if(n<a) {
    System.out.println("invalid input");

}
else
{
while(n>=a){
c= a+b;
a=b;
b=c;
if(n==a){
count++;
break;
}

}
}
if (count>0){
return true;
}
else {
return false;
}

}
}

fib2

from java.

 avatar commented on July 30, 2024

package fibono;

/**
*

  • @author Samikshya
    */
    public class FinoChecker {

    static boolean isFibonacciNumber(int n) {
    int n1 = 0, n2 = 1;
    boolean f = false;
    while (n >= n1) {
    if (n == n1) {
    f = true;
    break;
    }
    n2 = n1 + n2;
    n1 = n2 - n1;
    }
    return f;
    }
    }
    public class FiboNo {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      System.out.println("1 true:" + isFibonacciNumber(1));
      System.out.println("2 true:" + isFibonacciNumber(2));
      System.out.println("3 true:" + isFibonacciNumber(3));
      System.out.println("4 false:" + isFibonacciNumber(4));
      System.out.println("5 true:" + isFibonacciNumber(5));
      System.out.println("11 false:" + isFibonacciNumber(11));
      System.out.println("21 true:" + isFibonacciNumber(21));
      }

capture

}

}

from java.

Sudan15423 avatar Sudan15423 commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package tasks;

/**
*

  • @author Dragon15423
    */
    public class Tasks {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {

      // TODO code application logic here

      System.out.println("1 true:" + isFibonacciNumber(1));
      System.out.println("2 true:" + isFibonacciNumber(2));
      System.out.println("3 true:" + isFibonacciNumber(3));
      System.out.println("4 false:" + isFibonacciNumber(4));
      System.out.println("5 true:" + isFibonacciNumber(5));
      System.out.println("11 false:" + isFibonacciNumber(11));
      System.out.println("21 true:" + isFibonacciNumber(21));
      }

    static boolean isFibonacciNumber(int n) {

     int x, y = 1, z = 0;
     while (y < n) {
         x = z;
         z = y;
         y += x;
     }
     return y == n;
    

    }

}
task

from java.

kajalmaharjan avatar kajalmaharjan commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package fabonacciiseries;

/**
*

  • @author kajal
    */
    public class FabonacciiSeries {

    static boolean isFibonacciNumber(int n) {
    int n1 = 0, n2 = 1, n3, f = 0;

     if (n < n1) {
         System.out.println("invalid input");
     } else {
         while (n >= n1) {
    
             n3 = n1 + n2;
    
             n1 = n2;
             n2 = n3;
             if (n == n1) {
                 f++;
                 break;
             }
         }
     }
     if (f > 0) {
         return true;
     } else {
         return false;
     }
    

    }

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      int n;

      System.out.println("1 true:" + isFibonacciNumber(1));
      System.out.println("2 true:" + isFibonacciNumber(2));
      System.out.println("3 true:" + isFibonacciNumber(3));
      System.out.println("4 false:" + isFibonacciNumber(4));
      System.out.println("5 true:" + isFibonacciNumber(5));
      System.out.println("11 false:" + isFibonacciNumber(11));
      System.out.println("21 true:" + isFibonacciNumber(21));

    }

}
123

from java.

rabina12 avatar rabina12 commented on July 30, 2024

public static void main(String[] args) {
// TODO code application logic here
System.out.println("1 true:" + isFibonacciNumber(1));
System.out.println("2 true:" + isFibonacciNumber(2));
System.out.println("3 true:" + isFibonacciNumber(3));
System.out.println("4 false:" + isFibonacciNumber(4));
System.out.println("5 true:" + isFibonacciNumber(5));
System.out.println("11 false:" + isFibonacciNumber(11));
System.out.println("21 true:" + isFibonacciNumber(21));
}

static boolean isFibonacciNumber(int n) {

    int x, y = 1, z = 0;
    while (y < n) {
        x = z;
        z = y;
        y += x;
    }
    return y == n;
}

}
fs

from java.

kiir33 avatar kiir33 commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package fibonaccicheck;

/**
*

  • @author Kiran
    */
    public class FibonacciCheck {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      System.out.println("Checking Fibonacci number...");
      System.out.println("Fibonacci Check:0 true:"+ fibFunc(0));
      System.out.println("Fibonacci Check:1 true:"+ fibFunc(1));
      System.out.println("Fibonacci Check:2 true:"+ fibFunc(2));
      System.out.println("Fibonacci Check:3 true:"+ fibFunc(3));
      System.out.println("Fibonacci Check:12 false:"+ fibFunc(12));
      System.out.println("Fibonacci Check:13 false:"+ fibFunc(13));
      System.out.println("Fibonacci Check:21 true:"+ fibFunc(21));
      System.out.println("Fibonacci Check:22 false:"+ fibFunc(22));

    }
    static boolean fibFunc(int n){
    int a=0, b=1, c;
    while(a<=n) {
    if(a==n)
    return true;
    c=a+b;
    a=b;
    b=c;
    }
    return false;
    }
    }

Output:
capturefibonacci

from java.

sarumdr avatar sarumdr commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package fibocheck;

/**
*

  • @author sarumdr
    */
    public class Fibocheck {

    /**

    • @param args the command line arguments
      */
      static boolean isFibonacciNumber(int n) {
      int a = 0, b = 1, c, pos = 0;
      if (n < a) {
      System.out.println("invalid input");

      } else {
      while (n >= a) {
      c = a + b;
      a = b;
      b = c;

           if (n == a) {
               pos++;
               break;
           }
       }
      

      }
      if (pos > 0) {
      return true;
      } else {
      return false;
      }
      }

    public static void main(String[] args) {
    // TODO code application logic here

     System.out.println("1 true:" + isFibonacciNumber(1));
     System.out.println("2 true:" + isFibonacciNumber(2));
     System.out.println("3 true:" + isFibonacciNumber(3));
     System.out.println("4 false:" + isFibonacciNumber(4));
     System.out.println("5 true:" + isFibonacciNumber(5));
     System.out.println("11 false:" + isFibonacciNumber(11));
     System.out.println("21 true:" + isFibonacciNumber(21));
    

    }

}

OUTPUT
image

from java.

rivab avatar rivab commented on July 30, 2024

package day10fibonaccichecker;

/**
*

  • @author DELL
    */
    public class Day10fibonacciChecker {

    /**

    • @param args the command line arguments
      */
      static boolean isFibonacciNumber(int n) {
      int n1 = 0, n2 = 1, n3, f = 0;
      if (n < n1) {
      System.out.println("Fibonacci of negative number isnot possible");
      } else {
      while (n >= n1) {

           n3 = n1 + n2;
      
           n1 = n2;
           n2 = n3;
           if (n == n1) {
               f++;
               break;
           }
       }
      

      }
      if (f > 0) {
      return true;
      } else {
      return false;
      }
      }

    public static void main(String[] args) {
    // TODO code application logic here
    int n;
    System.out.println("1 true:" + isFibonacciNumber(1));
    System.out.println("2 true:" + isFibonacciNumber(2));
    System.out.println("3 true:" + isFibonacciNumber(3));
    System.out.println("4 false:" + isFibonacciNumber(4));
    System.out.println("5 true:" + isFibonacciNumber(5));
    System.out.println("11 false:" + isFibonacciNumber(11));
    System.out.println("21 true:" + isFibonacciNumber(21));

    }

}
day10

from java.

ajay987 avatar ajay987 commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package checker35;

import java.util.Scanner;

/**
*

  • @author Dell
    */
    public class Checker35 {

    static boolean isfibonnaccinumber(int n) {
    int f0 = 0, f1 = 1;
    while (f0 <= n) {
    if (f0 == n) {
    return true;
    }
    f1 = f1 + f0;
    f0 = f1 - f0;

     }
     return false;
    

    }

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      System.out.println("1 true :" + isfibonnaccinumber(1));
      System.out.println("2 true :" + isfibonnaccinumber(2));
      System.out.println("3 true :" + isfibonnaccinumber(3));
      System.out.println("4 false :" + isfibonnaccinumber(4));
      System.out.println("5 true :" + isfibonnaccinumber(5));
      System.out.println("8 true :" + isfibonnaccinumber(8));
      System.out.println("11 false :" + isfibonnaccinumber(11));
      System.out.println("21 true :" + isfibonnaccinumber(21));
      }

}
fibo

from java.

sthaanu avatar sthaanu commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package fibonaciicheck;

/**
*

  • @author admin
    */
    public class FibonaciiCheck {

    public static boolean isFibonacciNumber(int n) {
    int fib1 = 0;
    int fib2 = 1;
    do {
    int Fib1 = fib1;
    fib1 = fib2;
    fib2 = Fib1 + fib2;
    } while (fib2 < n);

     if (fib2 == n) {
         return true;
     } else {
         return false;
     }
    

    }

    public static void main(String[] args) {
    System.out.println("1 true:" + isFibonacciNumber(1));
    System.out.println("2 true:" + isFibonacciNumber(2));
    System.out.println("3 true:" + isFibonacciNumber(3));
    System.out.println("4 false:" + isFibonacciNumber(4));
    System.out.println("5 true:" + isFibonacciNumber(5));
    System.out.println("11 false:" + isFibonacciNumber(11));
    System.out.println("21 true:" + isFibonacciNumber(21));

    }
    }
    capture

from java.

syslin avatar syslin commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package settergetter;

/**
*

  • @author dell
    */
    public class FibinocSeries {

    public static void main(String[] args) {
    System.out.println("1 true:" + isFibonacciNumber(1));
    System.out.println("2 true:" + isFibonacciNumber(2));
    System.out.println("3 true:" + isFibonacciNumber(3));
    System.out.println("4 false:" + isFibonacciNumber(4));
    System.out.println("5 true:" + isFibonacciNumber(5));
    System.out.println("11 false:" + isFibonacciNumber(11));
    System.out.println("21 true:" + isFibonacciNumber(21));
    }

    static boolean isFibonacciNumber(int n) {

     int a = 0, b = 1, c, count = 0;
     while (n >= a) {
         c = a + b;
         a = b;
         b = c;
         if (n == a) {
             count++;
             break;
    
         }
    
     }
     if (count > 0) {
         return true;
     } else {
         return false;
     }
    

    }

}
111

from java.

sajanbasnet75 avatar sajanbasnet75 commented on July 30, 2024

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package javaapplication73;

/**
*

  • @author LORDsajan
    */
    public class JavaApplication73 {

    static boolean isFibonacaii(int x) {
    int a = 0, b = 1, c, d = 0;
    while (x >= a) {
    if (x < 0) {
    System.out.println("Invalid input");
    break;
    } else {
    c = a + b;
    a = b;
    b = c;
    if (x == a) {
    return true;
    }
    }
    }
    return false;
    }

    public static void main(String[] args) {
    System.out.println("1 true:" + isFibonacaii(1));
    System.out.println("2 true:" + isFibonacaii(2));
    System.out.println("3 true:" + isFibonacaii(3));
    System.out.println("4 false:" + isFibonacaii(4));
    System.out.println("5 true:" + isFibonacaii(5));
    System.out.println("8 true:" + isFibonacaii(8));
    System.out.println("11 false:" + isFibonacaii(11));
    System.out.println("21 true:" + isFibonacaii(21));

    }
    }
    capture

from java.

luckydivya avatar luckydivya commented on July 30, 2024

package fibonacci;

/**
*

  • @author PC
    */
    public class Fibonacci {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      System.out.println("1 true:" + isFibonacciNumber(1));
      System.out.println("2 true:" + isFibonacciNumber(2));
      System.out.println("3 true:" + isFibonacciNumber(3));
      System.out.println("4 false:" + isFibonacciNumber(4));
      System.out.println("5 true:" + isFibonacciNumber(5));
      System.out.println("11 false:" + isFibonacciNumber(11));
      System.out.println("21 true:" + isFibonacciNumber(21));
      }

    static boolean isFibonacciNumber(int n) {

     int x, y = 1, z = 0;
     while (y < n) {
         x = z;
         z = y;
         y += x;
     }
     return y == n;
    

    }

}
}

}
fibonacci pattern

from java.

rituratnam avatar rituratnam commented on July 30, 2024

CODE:
package fibonacci;

/**
*

  • @author User
    */
    public class Fibonacci {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      System.out.println("1 true:" + isFibonacciNumber(1));
      System.out.println("2 true:" + isFibonacciNumber(2));
      System.out.println("3 true:" + isFibonacciNumber(3));
      System.out.println("4 false:" + isFibonacciNumber(4));
      System.out.println("5 true:" + isFibonacciNumber(5));
      System.out.println("11 false:" + isFibonacciNumber(11));
      System.out.println("21 true:" + isFibonacciNumber(21));
      }
      static boolean isFibonacciNumber(int n) {

int x, y = 1, z = 0;
while (y < n) {
x = z;
z = y;
y += x;
}
return y == n;
}
}
Output
fibonacci

from java.

Rajjushrestha avatar Rajjushrestha commented on July 30, 2024

public class Fibonacci {

static boolean isFibonacciNumber(int n) {
    int n1 = 0, n2 = 1, n3, f = 0;

    if (n < n1) {
        System.out.println("invalid input");
    } else {
        while (n >= n1) {

            n3 = n1 + n2;

            n1 = n2;
            n2 = n3;
            if (n == n1) {
                f++;
                break;
            }
        }
    }
    if (f > 0) {
        return true;
    } else {
        return false;
    }
}

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    int n;

    System.out.println("1 true:" + isFibonacciNumber(1));
    System.out.println("2 true:" + isFibonacciNumber(2));
    System.out.println("3 true:" + isFibonacciNumber(3));
    System.out.println("4 false:" + isFibonacciNumber(4));
    System.out.println("5 true:" + isFibonacciNumber(5));
    System.out.println("11 false:" + isFibonacciNumber(11));
    System.out.println("21 true:" + isFibonacciNumber(21));

}

fb

from java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.