Posts

Showing posts with the label JAVA

Fibonacci Solution | Java Language

Image
The most famous Fibonacci problem solution in a java programming language is given below. IF YOU ARE A BEGINNER You will find it really helpful.  Theory : The idea of Fibonacci sires is that the third number is equal to the summation of the previous two numbers. Suppose 'a' = 0, and 'b' = 1, then the third number will be 'c' = 'a' + 'b'.  This means the sires will go like 0,1,1,2,3,5,8,13,21... Input -------------------------------------------- -------------------------------------------- package com.mycompany.basicjava; //THE NAME OF THE PACKAGE WILL NOT BE THE SAME import java.util.Scanner; // COPY THIS IF IT IS NOT IMPORTED. public class BasicJava { // PUBLIC CLASS MAYBE SOMETHING ELSE IN YOU IDE /* ----------START COPYING CODE FROM HERE---------------*/     public static void main(String[] args) { /* CHECK IF YOU HAVE WROTE THIS TWICE, IF YES, REMOVE ONE OF THEM*/         int m, b = 1, a = 0, sum = 0,j =0;         Scanner ...