Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Fibonacci-sequence/Java/fibonacci-sequence-1.java
Normal file
15
Task/Fibonacci-sequence/Java/fibonacci-sequence-1.java
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
public static long itFibN(int n)
|
||||
{
|
||||
if (n < 2)
|
||||
return n;
|
||||
long ans = 0;
|
||||
long n1 = 0;
|
||||
long n2 = 1;
|
||||
for(n--; n > 0; n--)
|
||||
{
|
||||
ans = n1 + n2;
|
||||
n1 = n2;
|
||||
n2 = ans;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue