#include <stdio.h>

int check_prime(int num)
{
	int	i;

	i = 2;
	while (i < num)
	{
		if (num % i == 0)
			return 0;
		i++;
	}
	return 1;
}

int ft_find_next_prime(int nb)
{
	if (nb <= 2)
		return 2;
	while (1)
	{
		if (check_prime(nb))
			return nb;
		nb++;
	}
}

int main()
{
	printf("%d\n", ft_find_next_prime(-1));
	printf("%d\n", ft_find_next_prime(0));
	printf("%d\n", ft_find_next_prime(1));
	printf("%d\n", ft_find_next_prime(2));
	printf("%d\n", ft_find_next_prime(3));
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: