Skip to content

Commit

Permalink
Create fibonacci
Browse files Browse the repository at this point in the history
  • Loading branch information
maram934 authored and x0lg0n committed Nov 1, 2024
1 parent 1110ce2 commit 24978fd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Java/fibonacci
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.*;

public class fibonacci {
public static void main(String[]hg){
Scanner sc = new Scanner(System.in);
int a=0;
int b=1;
int n = sc.nextInt();
int sum=0;
while(n>0){
sum+=a;
a = b;
b = sum;
n--;
}
System.out.println(sum);
sc.close();
}
}

0 comments on commit 24978fd

Please sign in to comment.