Skip to content

Commit

Permalink
Fibonacci
Browse files Browse the repository at this point in the history
  • Loading branch information
SHIVanshuSingh07 committed Feb 14, 2024
1 parent 6dd0d2f commit 418a58c
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//write a program to check whether a input n is part of Fibonacci Series
//if yes print true else false.


// ---------------------------------------------------------------------------------------------------------


import java.util.Scanner;
public class FibonacciNumber {

public class Solution {
public static boolean checkMember(int n){
int a = 0;
int b = 1;
int c;
while(a<n){
c=a+b;
a=b;
b=c;
}
if(a==n){
return true;
}else{
return false;
}
}
}
//pregiven code
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
System.out.println(Solution.checkMember(n));
s.close();
}

}

0 comments on commit 418a58c

Please sign in to comment.