package in.studyecart.impprograms; public class SECJAP111_1 { public static void main(String[] args) { //Fibonacci Series 0,1,1,2,3,5,8,13... without Recursive int val1=0,val2=1,val3=0,count=10; System.out.print(val1+","+val2); for(int i=2;i<count;i++) { val3=val1+val2; System.out.print(","+val3); val1=val2; val2=val3; } } } (code-box)
This Java program prints the first 10 numbers of the Fibonacci series, starting with 0 and 1. It does this without using a recursive function but instead uses a loop to calculate each number by adding the two previous numbers together.