Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
587 B
2
Indexable
Never
#include <stdio.h>

int isLucky(int num)
{
    while (num > 0)
    {
        int digit = num % 10;
        if (digit != 4 && digit != 7)
        {
            return 0; // Not a lucky number
        }
        num /= 10;
    }
    return 1; // It's a lucky number
}

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);

    int found = 0;
    for (int i = A; i <= B; i++)
    {
        if (isLucky(i))
        {
            printf("%d ", i);
            found = 1;
        }
    }

    if (!found)
    {
        printf("-1");
    }

    return 0;
}