How to Print Fibonacci Series in Apex Salesforce
- Abhilash Banpurkar
- Oct 12, 2022
- 1 min read
Updated: Jan 24, 2023
public class fibonacci {
public static void printnumber(){
integer n=10, firstterm =0,secondterm =1;
for(integer i=1;i<=n;i++){
integer nextterm = firstterm + secondterm;
firstterm=secondterm;
secondterm=nextterm;
system.debug('output' + nextterm);
}
}
}

EXECUTION IN ANANYMOUS WINDOW

OUTPUT:

Try to practice