/* Take a Range as input from user and print the prime number between it. */
/* Auhtor: Amit Dutta, Date: 20-11-2025 */

// This code has not been compiled.
// If you find any issues, please create a new issue on GitHub regarding them.
// Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues

#include <stdio.h>
#include <math.h>

int isPrime(int);

int isPrime(int n)
{
    if (n <= 1)
        return 0;
    if (n == 2)
        return 1;
    if (n % 2 == 0)
        return 0;
    int temp = (int)sqrt(n), i;
    for (i = 3; i <= temp; i += 2)
        if (n % i == 0)
            return 0;
    return 1;
}

int main()
{
    int lb, ub, i;
    printf("Enter the lower bound and the upper bound: ");
    scanf("%d %d", &lb, &ub);
    printf("\nPrime numbers between %d and %d:  ", lb, ub);
    for (i = lb; i <= ub; i++)
        if (isPrime(i))
            printf("%d  ", i);
    return 0;
}
