ProgrammingModerateSSC CGL Tier 2 · IBPS PO Mains
The number of trailing zeros in the decimal form of 2^20 5^3 is found by the procedure below, which divides out factors of 10 one at a time while the number ends in 0. What is printed?
The number of trailing zeros in the decimal form of 2^20 * 5^3 is found by the procedure below, which divides out factors of 10 one at a time while the number ends in 0. What is printed?
n = 2^20 * 5^3; count = 0
while n mod 10 == 0
n = n div 10; count = count + 1
end while
Print count- A. 3
- B. 20
- C. 4
- D. 6
Correct answer: A. 3
2^20 * 5^3 = 2^17 * 10^3, so exactly 3 factors of 10 divide it. Counting factors of 2 gives 20, counting factors of 5 and adding one gives 4, and doubling the 10-count gives 6.
Practise more Pseudocode and Code Tracing questionsPseudocode and Code Tracing: notes and key points
More Pseudocode and Code Tracing questions
- The procedure below computes the integer square root of 200 by testing r = 0, 1, 2, ... and stopping at the largest r with (r + 1) (r + 1)…
- The procedure below finds the smallest 0-based index i at which the prefix sum of [4, -1, 3, -2, 5] reaches at least 7. It prints i. What…
- Two sorted arrays a = [1, 4, 7] and b = [2, 3, 8, 9] are merged by the two-pointer procedure below, and the procedure prints the 4th…
- The procedure below repeatedly replaces x by the sum of its decimal digits, starting from x = 2^15, until x is a single digit, and prints…
- An array holds the values [3, 0, 2, 0, 1] (positions 0 to 4). The procedure below computes the water trapped above each position as…
- The Fibonacci sequence 1, 1, 2, 3, 5, ... is generated by the loop below, and the procedure prints how many terms are less than or equal…