Write a program in java to display the first ten terms of the following series...
1,2,4,7,11............
Plzz answer fast plzzz
Answers
Answered by
0
Answer:
in the form of numerical
Answered by
5
Well we need to print series 1,2,4,7…n
Logic-
(0+1 =1),( 1+ 1=2),( 2+ 2=4),(4+ 3=7),(7+4=11)…..
Procedure-
Assume a variable add with its initial value 1.
From logic its clear that we need to add previous number with 1,2,3,…
So logic will be add=add+i where I varies from 0 to 13.
For loop is used for executing code(add=add+i) number of times.
Code-
class number
{
Static public void main(String[]args)
{ int add=1;
for (int i=0;i<=13;i++)
{ add=add+i;
System.out.println(add);
}
}
}
Similar questions