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);
} 
}
} 


EXECUTION IN ANANYMOUS WINDOW

OUTPUT:


1 commentaire


Abhilash Banpurkar
Abhilash Banpurkar
05 févr. 2023

Try to practice

J'aime
bottom of page