피보나치 수열 소스코드

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

C언어[edit | edit source]

#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)); 
}