top of page

How to Print Fibonacci Series in Apex Salesforce

  • Writer: Abhilash Banpurkar
    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);
} 
}
} 

ree

EXECUTION IN ANANYMOUS WINDOW

ree

OUTPUT:

ree

1 Comment


Abhilash Banpurkar
Abhilash Banpurkar
Feb 05, 2023

Try to practice

Like
bottom of page