M. Nambiar has devised a mechanism to process any given number and thus generating a new resultant number. He calls this mechanism as the “Nambiar Number Generator” and the resultant number is referred to as the “Nambiar Number”.
Mechanism: In the given number, starting with the first digit, keep on adding all subsequent digits till the state (even or odd) of the sum of the digits is opposite to the state (odd or even) of the first digit. Continue this form the subsequent digit till the last digit of the number is reached. Concatenating the sums thus generates the Nambiar Number.
Input: N = 9880127431
First digit Next valid consecutive digits Resultant number 9880127431 9880127431 26 9880127431 9880127431 269 9880127431 9880127431 2697 9880127431 9880127431 26971
Input: N = 9866364552
Approach: For the first unused digit from the left check whether it is even or odd. If the digit is even then find the sum of consecutive digits starting at the current digit which is odd (even sum if the first digit was odd). Concatenate this sum to the resultant number and repeat the whole process starting from the first unused digit from the left.
Below is the implementation of the above approach:
- Pseudo Random Number Generator (PRNG)
- Random number generator in arbitrary probability distribution fashion
- Count number of trailing zeros in Binary representation of a number using Bitset
- Count number of triplets with product equal to given number with duplicates allowed
- Find minimum number to be divided to make a number a perfect square
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Number of ways to split a binary number such that every part is divisible by 2
- Given number of matches played, find number of teams in tournament
- Number of times the largest perfect square number can be subtracted from N
- Find count of digits in a number that divide the number
- Find the largest good number in the divisors of given number N
- Find the number of integers x in range (1,N) for which x and x+1 have same number of divisors
- Number of times a number can be replaced by the sum of its digits until it only contains one digit
- Find maximum number that can be formed using digits of a given number
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.