30 lines
1.1 KiB
C
30 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_pow.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/05/23 23:04:24 by bgoulard #+# #+# */
|
|
/* Updated: 2024/05/24 01:01:06 by bgoulard ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stddef.h>
|
|
|
|
size_t ft_pow(size_t x, size_t y)
|
|
{
|
|
size_t res;
|
|
|
|
res = 1;
|
|
if (y == 0)
|
|
return (1);
|
|
if (x == 0)
|
|
return (0);
|
|
while (y > 0)
|
|
{
|
|
res *= x;
|
|
y--;
|
|
}
|
|
return (res);
|
|
}
|