Last active
October 7, 2020 11:22
-
-
Save sriniind19/98fea4ef7acb4856a7657ebc75c162ce to your computer and use it in GitHub Desktop.
Fibonacci Series for a given input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fibonacci { | |
public String getnerateFibbonaci(Integer num) { | |
String fibobonaciSeries = 'Fibonacci Series: '; | |
Integer f1 = 0, f2 = 1, nextNum = 0; | |
for(Integer i=0;i<num;i++) { | |
nextNum = f1 + f2; | |
f1 = f2; | |
f2 = nextNum; | |
fibobonaciSeries += ', '+String.valueOf(nextNum); | |
} | |
return fibobonaciSeries; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment