## Total number of non-decreasing numbers with n digits

A number is non-decreasing if every digit (except the first one) is greater than or equal to previous digit. For example, 223, 4455567, 899, are… Read More »

## Check if a given number can be represented in given a no. of digits in any base

Given a number and no. of digits to represent the number, find if given number can be represented in given no. of digits in any… Read More »

## Program to check if a given number is Lucky (all digits are different)

A number is lucky if all digits of the number are different. How to check if a given number is lucky or not. Examples: Input:… Read More »

## Compute sum of digits in all numbers from 1 to n

Given a number x, find sum of digits in all numbers from 1 to n. Examples: Input: n = 5 Output: Sum of digits in… Read More »

## Remove repeated digits in a given number

Given an integer, remove consecutive repeated digits from it. Examples: Input: x = 12224 Output: 124 Input: x = 124422 Output: 1242 Input: x =… Read More »

## Build Lowest Number by Removing n digits from a given number

Given a string ‘str’ of digits and an integer ‘n’, build the lowest possible number by removing ‘n’ digits from the string and not changing… Read More »

## Replace all ‘0’ with ‘5’ in an input Integer

Given a integer as a input and replace all the ‘0’ with ‘5’ in the integer. Examples: 102 – 152 1020 – 1525 Use of… Read More »

## Print first k digits of 1/n where n is a positive integer

Given a positive integer n, print first k digits after point in value of 1/n. Your program should avoid overflow and floating point arithmetic. Examples… Read More »

## Find next greater number with same set of digits

Given a number n, find the smallest number that has same set of digits as n and is greater than n. If x is the… Read More »

## Find the smallest number whose digits multiply to a given number n

Given a number ‘n’, find the smallest number ‘p’ such that if we multiply all digits of ‘p’, we get ‘n’. The result ‘p’ should… Read More »

## Find all possible interpretations of an array of digits

Consider a coding system for alphabets to integers where ‘a’ is represented as 1, ‘b’ as 2, .. ‘z’ as 26. Given an array of… Read More »

## Write a program to reverse digits of a number

Write a program to reverse digits of an integer. Examples : Input : num = 12345 Output : 54321 Input : num = 876 Output… Read More »

## Program for Sum the digits of a given number

Given a number, find sum of its digits. Examples : Input : n = 687 Output : 21 Input : n = 12 Output :… Read More »