JAVA_Fibonacci Number_LeetCode 509


JAVA_Fibonacci Number_LeetCode 509

JAVA_Fibonacci Number_LeetCode 509 풀이 class Solution { public int fib(int n) { if(n <= 1) return n; int a = 0, b = 1; for(int i = 2;i <= n;i++) { int sum = a + b; a = b; b = sum; } return b; } } * 출처 Fibonacci Number - LeetCode Fibonacci Number - The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n - 2), for n > 1. Given n, c...


#FibonacciNumber_LeetCode509 #JAVA #JAVA_FibonacciNumber #JAVA_FibonacciNumber_LeetCode509 #JAVA_LeetCode509

원문링크 : JAVA_Fibonacci Number_LeetCode 509