ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
def fact(n):
    return 1 if n <= 1 else n * fact(n - 1)
print(len(str(fact(25))), fact(25) % 10 ** 6 == 0, fact(25) % 7)
  1. A. 26 True 0
  2. B. 26 False 0
  3. C. 25 True 0
  4. D. 26 True 1

Correct answer: A. 26 True 0

25! has 26 digits. It has six trailing zeros, so it is divisible by 10**6. It contains the factor 7, so its remainder modulo 7 is 0.

More Python Programming questions

Exams that ask this topic