23 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/* ************************************************************************** */
 | 
						|
/*                                                                            */
 | 
						|
/*                                                        :::      ::::::::   */
 | 
						|
/*   ft_fibonacci.c                                     :+:      :+:    :+:   */
 | 
						|
/*                                                    +:+ +:+         +:+     */
 | 
						|
/*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */
 | 
						|
/*                                                +#+#+#+#+#+   +#+           */
 | 
						|
/*   Created: 2022/07/20 10:23:01 by cchauvet          #+#    #+#             */
 | 
						|
/*   Updated: 2022/07/25 17:30:54 by cchauvet         ###   ########.fr       */
 | 
						|
/*                                                                            */
 | 
						|
/* ************************************************************************** */
 | 
						|
 | 
						|
int	ft_fibonacci(int index)
 | 
						|
{
 | 
						|
	if (index == 0)
 | 
						|
		return (0);
 | 
						|
	if (index == 1)
 | 
						|
		return (1);
 | 
						|
	if (index < 0)
 | 
						|
		return (-1);
 | 
						|
	return (ft_fibonacci(index - 1) + ft_fibonacci(index - 2));
 | 
						|
}
 |