Lucas Series

Lucas Series are similar to Fibonacci Series. Lucas Series are also defined as the sum of its two immediately previous numbers. As compare to the Fibonacci number here the first two terms are 2 and 1 instead of 0 and 1.

For Example:  2,1, 3, 4, 7, 11, 18, 29... 

Print the fibonacci series upto 8 digit.

					
	public class Lucas {
	    public static void main(String[] args) {
	
	        int count = 8, num1 = 2, num2 = 1;
	        System.out.print("Lucas Series of "+count+" numbers:");
		    int sumOfNum; 
  
  		      for (int i = 2; i <= n; i++){ 
           			 sumOfNum = num1 + num2;  // Add the first 2 number
			         num1 = num2;   // Assign the num2 in num1 
			         num2 = sumOfNum;  // assign sumof 2 number in mun2
					
					System.out.println(num2+",");
			  } 
			}
		}
					
Output:  2,1, 3, 4, 7, 11, 18, 29...