31 lines
1.1 KiB
C
31 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_power.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/10/10 22:50:22 by erey-bet #+# #+# */
|
|
/* Updated: 2022/10/10 22:50:31 by erey-bet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "ft_printf.h"
|
|
|
|
int ft_power(int nb, int power)
|
|
{
|
|
int i;
|
|
int new_nb;
|
|
|
|
if (power < 0)
|
|
return (0);
|
|
i = 0;
|
|
new_nb = 1;
|
|
while (i < power)
|
|
{
|
|
i++;
|
|
new_nb *= nb;
|
|
}
|
|
return (new_nb);
|
|
}
|