피보나치 수열 소스코드

From IT Wiki
Revision as of 01:40, 11 July 2019 by 123.109.205.2 (talk) (→‎C언어)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

C언어

#include <stdio.h>
int dp[100];

int fib(int n) { 
  if(dp[n]) return dp[n];
  if(n<=1) return n; 
  else return dp[n] = fib(n-1)+fib(n-2);
} 

int main() { 
  printf("%d", fib(35)); 
}