Challenge - 5 Problems
Math & Number Theory Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Euclidean Algorithm for GCD
What is the output of this code that finds the greatest common divisor (GCD) of 48 and 18 using the Euclidean algorithm?
DSA Python
def gcd(a, b): while b != 0: a, b = b, a % b return a print(gcd(48, 18))
Attempts:
2 left
💡 Hint
Remember the Euclidean algorithm repeatedly replaces the larger number by the remainder until zero.
✗ Incorrect
The Euclidean algorithm finds the GCD by repeatedly taking remainders. gcd(48,18) = gcd(18,12) = gcd(12,6) = gcd(6,0) = 6.
❓ Predict Output
intermediate2:00remaining
Output of Prime Check Function
What is the output of this code that checks if 29 is a prime number?
DSA Python
def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True print(is_prime(29))
Attempts:
2 left
💡 Hint
A prime number has no divisors other than 1 and itself.
✗ Incorrect
29 is a prime number because it has no divisors other than 1 and 29.
🧠 Conceptual
advanced2:00remaining
Why Modular Arithmetic is Used in DSA
Why do many algorithms in data structures and algorithms use modular arithmetic (like modulo operations) when dealing with large numbers?
Attempts:
2 left
💡 Hint
Think about what happens when numbers get very big in computers.
✗ Incorrect
Modular arithmetic keeps numbers within a fixed range, preventing overflow and making calculations manageable.
❓ Predict Output
advanced2:00remaining
Output of Fibonacci with Modulo
What is the output of this code that calculates the 10th Fibonacci number modulo 100?
DSA Python
def fib_mod(n, m): a, b = 0, 1 for _ in range(n): a, b = b, (a + b) % m return a print(fib_mod(10, 100))
Attempts:
2 left
💡 Hint
Calculate Fibonacci numbers step by step and apply modulo 100 each time.
✗ Incorrect
The 10th Fibonacci number is 55, and 55 % 100 is 55.
🧠 Conceptual
expert3:00remaining
Role of Number Theory in Cryptography Algorithms
Which of the following best explains why number theory is crucial in cryptography algorithms used in data security?
Attempts:
2 left
💡 Hint
Think about what makes encryption hard to break.
✗ Incorrect
Cryptography relies on hard problems like factoring large primes and modular exponentiation, which come from number theory.