- 2
Make this program 1+1+2+3+5............n
5 Answers
+ 1
Excuse me sir I want it in java
+ 1
Wich language ?
0
import java.util.*;
public class Program
{
public static void main(String[] args) {
Scanner in = new Scanner (System .in);
int i,a=1,b=1,s=0;
int n= in.nextInt();
//n is the value of number of iritetion plz enter at the run time
for(i=1;i<=n;i++){
s=a+b;
a=b;
b=s;
}
System .out .print (s-1);
}
}
0
0
Java