Given a decimal number N, the task is to check if a number has consecutive zeroes or not after converting the number to its K-based notation.
Input: N = 4, K = 2
4 in base 2 is 100, As there are consecutive 2 thus the answer is No.
Input: N = 15, K = 8
15 in base 8 is 17, As there are no consecutive 0 so the answer is Yes.
Approach: First convert the number N into base K and then simply check if the number has consecutive zeroes or not.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Given a number N in decimal base, find number of its digits in any base (base b)
- Check if a N base number is Even or Odd
- Check if a number is in given base or not
- Check if a number N starts with 1 in b-base
- Check if a given number can be represented in given a no. of digits in any base
- Check if the number is even or odd whose digits and base (radix) is given
- Check if a number is power of k using base changing method
- Find the Nth digit from right in base B of the given number in Decimal base
- Given a number N in decimal base, find the sum of digits in any base B
- Count of N-digit numbers in base K with no two consecutive zeroes
- Check if a number can be written as sum of three consecutive integers
- Check if a number can be expressed as a sum of consecutive numbers
- C++ program to find all numbers less than n, which are palindromic in base 10 and base 2.
- Add two integers of different base and represent sum in smaller base of the two
- Complement of a number with any base b
- Pandigital number in a given base
- Largest N digit number in Base B
- Largest value of x such that axx is N-digit number of base b
- Number System and Base Conversions
- Find most significant bit of a number X in base Y
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.