7.5k views
5 votes
Create a truth table of the function PRIME(A,B,C,D) where A,B,C,D are the bits of a 4-bit number. A is the highest significant bit and D is the least significant.

User Kyaw Tun
by
8.8k points

1 Answer

5 votes

Answer:

The output is 1 for:


1_(10) = (0001)_(2)


2_(10) = (0010)_(2)


3_(10) = (0011)_(2)


5_(10) = (0101)_(2)


7_(10) = (0111)_(2)


11_(10) = (1011)_(2)


13_(10) = (1101)_(2)

Explanation:

The first step is creating the truth table, from the most significant bit to the least significant. Then, each value is converted to decimal, like these two examples:


(1111)_(2) = 1*2^(0) + 1*2^(1) + 1*2^(2) + 1*2^(3) = 15


(1110)_(2) = 0*2^(0) + 1*2^(1) + 1*2^(2) + 1*2^(3) = 14

After the conversion, if the decimal equivalent of the 4-bit number is prime, the output is 1.

So, the output is 1 for 1,2,3,5,7,11,13

So

A - B - C - D - Decimal - Output

0 - 0 - 0 - 0 - 0 - 0

0 - 0 - 0 - 1 - 1 - 1

0 - 0 - 1 - 0 - 2 - 1

0 - 0 - 1 - 1 - 3 - 1

0 - 1 - 0 - 0 - 4 - 0

0 - 1 - 0 - 1 - 5 - 1

0 - 1 - 1 - 0 - 6 - 0

0 - 1 - 1 - 1 - 7 - 1

1 - 0 - 0 - 0 - 8 - 0

1 - 0 - 0 - 1 - 9 - 0

1 - 0 - 1 - 0 - 10 - 0

1 - 0 - 1 - 1 - 11 - 1

1 - 1 - 0 - 0 - 12 - 0

1 - 1 - 0 - 1 - 13 - 1

1 - 1 - 1 - 0 - 14 - 0

1 - 1 - 1 - 1 - 15 - 0

User Carlo Pecchia
by
8.9k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories