I was asked to code for the given problem, but I am still unable to get a substantial solution for the same.
for :
input : 3
output : 9
for :
input: 4
output: 252
Solution Please!
def count(n):
# Calculate the total number of n-digit numbers
total = 10 ** n
# Calculate the number of n-digit numbers with no zeroes
a_n = [1, 2]
for i in range(2, n):
a_n.append(a_n[i-1] + a_n[i-2])
# Calculate the number of n-digit numbers with at least two zeroes
total_Nums = total - a_n[-1] - (9 * (10 ** (n-1)))
return total_Nums
tried this but not giving the output
New contributor
Akrit Rihal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.