## Description

1. [Weight = 1] What does the pseudocode below generate?

for outer in [1,2] do

for middle in [3,4,5] do

for inner in [6,7] do

print(outer,inner,middle)

Function print(a,b,c)

Input: three integers a, b, and c

Output: print a first, separated by a space, and then print

b, separated by a space, and lastly print c. After

that the next print() will start from a new line.

2. [Weight = 1] Another important mathematical constant is called Euler’s number (usually

denoted by e) which is given by

Let us consider only n = 0, 1, …, 6. Convert this decimal number to binary. You may

consider only five digits after the radix point in the binary representation.

3. [Weight = 3] To convert a decimal number to binary, as you know already, is to keep

dividing the number (or quotient) by 2 and assign the remainder (either 0 or 1) to ai,

where i +1> 0 is the number of times the division performed until the quotient is 0. In

this question, you are asked to write pseudocode for this algorithm. The specification of

the function is given below.

Function dec_to_bin(n)

Input: n is a positive integer in decimal.

Output: A list L = [a0, a1, a2, …], where a0a1a2… … a2a1a0 is the binary

representation of n.

You may use L[i] c, c = 0, 1 for assigning c to the ith element in L. Note that i starts

from 0. There are also two functions available to you:

Function mod_2(n)

Input: n is a positive integer in decimal.

Output: the remainder of n divided by 2.

Function div_2(n)

Input: n is a positive integer in decimal.

Output: the quotient of n divided by 2.