How to solve a series program in java programming language
Answers
Answer:
The basic steps to create the Hello World program are: write the program in Java, compile the source code, and run the program.
Write the Java Source Code. ...
- Save the File. ...
- Open a Terminal Window. ...
- The Java Compiler. ...
- Change the Directory. ...
- Compile Your Program. ...
- Run the Program.
Answer:
solving series problem more requires your logical thinking than coding skill
first of all you need to interpret what's logic behind the series.
like in fibonacci series nth term is sum of (n-1)th and (n-2)th term
now you can easily write your program
use for loops to limit till which term you need the series and write the expression for the logic of series in the loop block
Explanation:
like a program for fibonacci series:-
class Fibonacci{
public static void main(String args[])
{
int n1=0,n2=1,n3,i,count=10;
System.out.print(n1+" "+n2);
for(i=2;i<count;++i)
{
n3=n1+n2;
System.out.print(" "+n3);
n1=n2;
n2=n3;
}
}}
2 terms are already printed so loop is called for n-2 times
and the inner part contains the logic
summation of n-1 and n-2 term
n1 contains n-2th and n2 contains n-1th term