Same principle as the previous post. Fill up the truth table and derive the equation and simplify it as much as possible. 4 bit integer from 0000 to 1111 or 0 to 15. Do the prime number check for 0 to 15 and fill up the truth table as done below.

A B C D Output F

0 0 0 0----0

0 0 0 1----0

0 0 1 0----1

0 0 1 1----1

0 1 0 0----0

0 1 0 1----1

0 1 1 0----0

0 1 1 1----1

1 0 0 0----0

1 0 0 1----0

1 0 1 0----0

1 0 1 1----1

1 1 0 0----0

1 1 0 1----1

1 1 1 0----0

1 1 1 1----0

I hope it helps and you will be able to derive the equation and simplify it