Skip to content

Instantly share code, notes, and snippets.

@sriniind19
Last active October 7, 2020 11:22
Show Gist options
  • Save sriniind19/98fea4ef7acb4856a7657ebc75c162ce to your computer and use it in GitHub Desktop.
Save sriniind19/98fea4ef7acb4856a7657ebc75c162ce to your computer and use it in GitHub Desktop.
Fibonacci Series for a given input
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