In this, we are going to write a simple program to find the sum of 1st 10 numbers of Lucas
series in Java.
class Lucas
{
public static void main(String[] args)
{
int i, n = 0, f = 2, s = 1, t, sum = 0;
System.out.println("Lucas Series 1 element : 2");
System.out.println("Lucas Series 2 element : 1");
for (i = 1; i <= 8; i++)
{
t = f + s;
sum += t;
f = s;
s = t;
n = i + 2;
System.out.println("Lucas Series " + n + " element : " + sum);
sum = 0;
}
}
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP