Comments (19)
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);
}
} - @param args the command line arguments
from java.
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; } }
- @param args the command line arguments
}
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));
}
from java.
/*
- 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));
}
- @param args the command line arguments
from java.
/*
- 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));
}
}
from java.
/*
- 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"); - @param args the command line arguments
}
else
{
while(n>=a){
c= a+b;
a=b;
b=c;
if(n==a){
count++;
break;
}
}
}
if (count>0){
return true;
}
else {
return false;
}
}
}
from java.
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));
}
- @param args the command line arguments
}
}
from java.
/*
- 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;
}
-
from java.
/*
- 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));
}
-
from java.
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;
}
from java.
/*
- 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;
}
} - @param args the command line arguments
from java.
/*
- 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 hereSystem.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));
}
-
}
from java.
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));}
-
from java.
/*
- 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));
}
- @param args the command line arguments
from java.
/*
- 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));
from java.
/*
- 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; }
}
from java.
/*
- 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));
from java.
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;
}
- @param args the command line arguments
}
}
from java.
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) {
- @param args the command line arguments
int x, y = 1, z = 0;
while (y < n) {
x = z;
z = y;
y += x;
}
return y == n;
}
}
Output
from java.
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));
}
from java.
Related Issues (20)
- Initial Design - CGPA Calculator HOT 1
- Initial Design - Blood Bank HOT 1
- Initial Design - CMS HOT 1
- Initial Design - RMS HOT 1
- Initial Design - SMS HOT 1
- Initial Design - FDC HOT 1
- Initial Design - HRS HOT 1
- Initial Design - DSMS HOT 1
- Some Screenshots - SRP HOT 1
- Some Screenshots - KLMS HOT 1
- Submit - Login UI HOT 6
- Build UI Better HOT 3
- Submit - Initial Screenshots, Source Code & Database HOT 4
- Submit - Concept Work of Your Project
- Design & Develop a Simple Calculator HOT 9
- Develop - PIN Breaker HOT 3
- Refresh JTable HOT 3
- Splash Screen - Loading
- Submit your Project Title HOT 26
- Project Submission Deadline: 31st Ashoj, 2017 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java.