mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
feat(solutions): add fibonacci/c/function
This commit is contained in:
3
challenges/fibonacci/solutions/c/function/README.md
Normal file
3
challenges/fibonacci/solutions/c/function/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# fibonacci/c/function
|
||||||
|
|
||||||
|
Created by [@Divlo](https://github.com/Divlo) on 29 September 2021.
|
13
challenges/fibonacci/solutions/c/function/solution.c
Normal file
13
challenges/fibonacci/solutions/c/function/solution.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int fibonacci(int number) {
|
||||||
|
return number < 2 ? number : fibonacci(number - 1) + fibonacci(number - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int number;
|
||||||
|
scanf("%d", &number);
|
||||||
|
printf("%d\n", fibonacci(number));
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Reference in New Issue
Block a user