#include <unistd.h>
#include <stdio.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
write(1, &str[i], 1);
i++;
}
}
void ft_putnbr(int nb)
{
if (nb >= 0 && nb <= 9)
ft_putchar(nb + '0');
else
{
ft_putnbr(nb / 10);
ft_putnbr(nb % 10);
}
}
void ft_fizzbuzz(int n)
{
int i;
i = 1;
while (i <= n )
{
if(i % 3 == 0 && i % 5 == 0)
{
ft_putstr("fizzbuzz\n");
}
else if (i % 3 == 0)
{
ft_putstr("fizz\n");
}
else if (i % 5 == 0)
{
ft_putstr("buzz\n");
}
else if (i <= 9)
{
ft_putchar(i + '0');
ft_putchar('\n');
}
else if (i > 9)
{
ft_putnbr(i);
ft_putchar('\n');
}
i++;
}
}
int main(void)
{
ft_fizzbuzz(100);
return (0);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: