 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can print and terms of Febonaki series in Hava. So first understand the terms of Febonaki series. So here you can see I have typed some digits which are numbers of Febonaki series. 0, 0, sorry, in place of 0 here, 1 is required. So 0, 1, 1, 2, 3, 5, 8, 13, 21 and so on. So now we have to find out the logic. You can see that if I add initial 2 numbers, then I can find out the next number. So 0 plus 1 is 1, 1 plus 1 is 2, 2 plus 1 is 3, 3 plus 2 is 5, 5 plus 3 is 8 and so on. So this way we have to add 2 numbers so that we can find out the next number of Febonaki series. Now I am going to import scanner class which is available in util package. Then I am defining a class whose name is Febonaki. Inside this class, I am going to define main function. Inside this main function, I am going to implement the logic which will print Febonaki series on output screen. So first I am going to declare some variables. I am going to create instance of scanner class. Here I am passing system.in as constructor value. It decides that all the inputs will be received from console. Now with the help of system.out.println, I am going to print the message. This is how many numbers of Febonaki you want to print. So user will decide how many digits of Febonaki series he or she want to print on output screen. So I am going to read that value with help of next int method. So this next int method is defined in scanner class. That's why I have imported scanner class. So the number of digits will be available in n. Now I can iterate a loop n times. This loop will repeat n times and it will print n terms of Febonaki series on output screen. So first I am going to print value of temp and after each digit comma will be displayed or we can type 3 dots. Then temp equals to temp1 plus temp2. This is the logic which I have already explained you. Temp1 and temp2 are added into temp. Now temp1 equals to temp2 and temp2 equals to temp. So here I am assigning value of temp2 into temp1 and value of temp into temp2. So this is the logic to print Febonaki series on output screen and this loop will print n terms of Febonaki series. Now I am going to save this code. This code is saved in d drive in Java folder with the name Febonaki.java. So for compilation and execution I am going to open command prompt. Now I am moving to d drive in Java folder. So my current location is d drive in Java folder. Here I can compile the code with the command javac space Febonaki.java. So it is compiled successfully. It means code doesn't contain any error. Now I can execute this code with the help of command java Febonaki. You can see it is asking for a value how many numbers of Febonaki you want to print. I am entering 10. So it will print 10 digits of Febonaki series. You can see here. But here numbers are printed in separate lines. This is because I have used system.out.println. Println always prints a particular value in new line. If you want to print it in a particular line, remove ln from println statement. I am saving this code again. I am compiling this code again and I am executing it. Again it is asking for the number I am entering 10. You can see the output. This time it is printing all the digits in a single line. So you can compare both the output. Both are having same values. You can also match the pattern. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34. You can add any particular two numbers. The addition of those two numbers will be the result of next number. If I add 3 and 5, the next number will be 8 which is the addition of 3 and 5. I hope you have understood how we can print n terms of Febonaki series on output screen in case of java. If you want to watch more programming related videos, you can follow my YouTube channel. Thank you for watching this video.