Name: _____________________________________________________
Up to 5 handwritten pages are allowed.
1. Translate, step-by-step, the following for-loop into a primitive recursive expression:
int x = p + q;
for (int i = 1; i <= r; i++)
{x = x * q;}
You can use add(.,.) (sum) and
mult(., .) (product) in this expression.
What is the value of this
function when p = 1, q = 2, and r = 2?
int z = p + q;
for(int i = 1; i <= r; i++)
{for (int j = 1; j <= s; j++)
{z = z * q;}}
You can use add(.,.) and mult(., .) in this expression.
What is the value of this
function when p = q = r = s = 2?