feat(math/power): adding a function to calculate power

This commit is contained in:
Raphael 2025-09-17 16:42:42 +02:00
parent d8ac7d2b88
commit c27526bc24
No known key found for this signature in database

30
math/ft_power.c Normal file
View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/17 16:08:00 by rparodi #+# #+# */
/* Updated: 2025/09/17 16:12:39 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdint.h>
uint64_t ft_power(uint64_t base, uint64_t exponent)
{
uint64_t i;
uint64_t result;
i = 0;
result = 1;
if (exponent == 0)
return (1);
while (i < exponent)
{
result *= base;
i++;
}
return (result);
}