Accenture Accenture Primer Practice Question
BEGINAnswer options
A
DECLARE variables i, factorial
B
SET factorial <-- 1
C
FOR i<--1 to 5 do
D
factorial <--factorial * i
E
i <-- i+1
F
END FOR
G
PRINT factorial
H
END
I
Which of the following statement should be inserted to complete the above pseudo code for finding factorial of 5 numbers.
J
The logic for finding a factorial is factorial * index
Correct answer: factorial <--factorial * i
Explanation
The question asks which statement should be inserted to complete the factorial pseudocode. Option 9 hints 'The logic for finding a factorial is factorial * index', pointing to option 3: 'factorial <-- factorial * i', which is the core computation statement inside the FOR loop that multiplies the running factorial by the current index i.