What does the following function do? def fun(n): d2 = set() for i in range(1,…

PYQ Capgemini Hiring Assessment 2025

What does the following function do?

def fun(n):
    d2 = set()
    for i in range(1, int(sqrt(n) + 1)):
        if n % i == 0:
            d2.add(i)
            d2.add(n // i)
    return list(d2)
  1. A.

    Finds the prime numbers upto n

  2. B.

    Finds remainders when divided by n

  3. C.

    Finds all divisors of a number

  4. D.

    Finds the GCD of a number

Attempted by 171 students.

Sign up free to check your answer

Sign up free

Explore the full course: Capgemini Preparation

Loading lesson…