Finally! A worthy opponent!

Report a typo

Which of these programs will output the same answer if a=5a = 5?

1)

// PSEUDOCODE 1

x = 1

for i in (1, a):
    x = x * i

print(x)

2)

// PSEUDOCODE 2

function punk(x):
    f = 1
    for j in (1, x): 
        f = f * j
    return f

print(punk(a))

3)

// PSEUDOCODE 3

x = 1

for i in (1, a):
    for j in (1, a):
        if i > j then:
            x = x * j
        else:
            x = x / j
    x = x * i

print(x)

4)

// PSEUDOCODE 4

k = 1
i = 1

while k <= a:
    i = i * k
    k = k + 1

print(i)
Select one option from the list
___

Create a free account to access the full topic