Problem 45436. Successive zeros
Suppose n is the number of digits a number contains. Now,
12032 - is a valid n=5 digit number. But 10023 - is defined as invalid -- because it contains two successive zeros.
Calculate the number of n-digit numbers that do not contain successive d-number of zeros.
Solution Stats
Problem Comments
-
3 Comments
I really like this problem, but I'm confused by one of the test cases. It asserts that num_count(2,2) is 90. If I'm reading that correctly, that means the number of two digit numbers without two successive zeros should be 90. But I can only think of one two digit number with two successive zeros: 00. Am I misinterpreting something?
Dear Ned,
num_count(2,2) == [10 : 99]
so total 2 digit numbers 'without' 2 successive zeros = 90 [since from 10 to 99, none of them contains 2 successive zeros].
now, '00' is not considered as a two digit number. similarly '023' is not considered as a 3 digit number.
I've considered the integer sequence here.
Am I wrong or is the problem actually requesting at least d-number of sucessive zeros? Having exactly d-number of sucessive zeros, and having at least d-number of sucessive zeros are two different cases. And the problem should specify which is the case required.
Solution Comments
Show commentsProblem Recent Solvers16
Suggested Problems
-
Find the sum of all the numbers of the input vector
49120 Solvers
-
5902 Solvers
-
Project Euler: Problem 4, Palindromic numbers
1042 Solvers
-
420 Solvers
-
4946 Solvers
More from this Author165
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!