In how many ways can the letters of the word "MISSISSIPPI" be arranged?
What is the formula for calculating the number of combinations?
What will be the output of the following code?
def count_lucky_numbers(n):
count = 0
for i in range(1, n + 1):
if '4' in str(i) or '7' in str(i):
count += 1
return count
print(count_lucky_numbers(100))
What will be the output of the following code?
def pow_mod(x, n, d):
result = 1
for _ in range(n):
result = (result * x) % d
return result
print(pow_mod(3, 4, 5))
What will be the output of the following code?
def permutation_partitions(n, k):
if n == 0 or k == 1:
return 1
elif n < k:
return 0
else:
return k * permutation_partitions(n - 1, k) + permutation_partitions(n - 1, k - 1)
print(permutation_partitions(5, 3))
What will be the output of the following code?
def combinations(n, r):
if r == 0 or n == r:
return 1
else:
return combinations(n - 1, r - 1) + combinations(n - 1, r)
print(combinations(6, 2))
What is the output of the following code?
def count_permutations(n):
if n == 0:
return 1
else:
return n * count_permutations(n - 1)
def count_partitions(n, k):
if k == 1 or n == k:
return 1
elif k > n:
return 0
else:
return count_partitions(n - 1, k - 1) + k * count_partitions(n - 1, k)
result = count_permutations(5) % count_partitions(10, 2)
print(result)
What is the output of the following code?
def count_combinations(n, r):
if r == 0 or n == r:
return 1
else:
return count_combinations(n - 1, r - 1) + count_combinations(n - 1, r)
def pow_mod(x, n, d):
if n == 0:
return 1
else:
temp = pow_mod(x, n // 2, d)
if n % 2 == 0:
return (temp * temp) % d
else:
return (x * temp * temp) % d
result = count_combinations(5, 2) % pow_mod(2, 10, 7)
print(result)
What is the output of the following code?
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n - 1)
def pow_mod(x, n, d):
if n == 0:
return 1
else:
temp = pow_mod(x, n // 2, d)
if n % 2 == 0:
return (temp * temp) % d
else:
return (x * temp * temp) % d
result = factorial(5) % pow_mod(3, 4, 5)
print(result)
What is the output of the following code?
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n - 1)
def pow_mod(x, n, d):
if n == 0:
return 1
else:
temp = pow_mod(x, n // 2, d)
if n % 2 == 0:
return (temp * temp) % d
else:
return (x * temp * temp) % d
result = factorial(5) % pow_mod(3, 4, 5)
print(result)
What is the output of the following code?
def pow_mod(x, n, d):
if n == 0:
return 1
else:
temp = pow_mod(x, n // 2, d)
if n % 2 == 0:
return (temp * temp) % d
else:
return (x * temp * temp) % d
def count_permutations(n):
if n == 0:
return 1
else:
return n * count_permutations(n - 1)
result = pow_mod(count_permutations(5), 2, 7)
print(result)
What is the output of the following code?
def count_partitions(n, k):
if k == 1 or n == k:
return 1
elif k > n:
return 0
else:
return count_partitions(n - 1, k - 1) + k * count_partitions(n - 1, k)
def combinations(n, r):
if r == 0 or n == r:
return 1
else:
return combinations(n - 1, r - 1) + combinations(n - 1, r)
result = count_partitions(combinations(6, 2), 3)
print(result)