Let 1 represent ‘A’, 2 represents ‘B’, etc. Given a digit sequence, count the number of possible decodings of the given digit sequence.
This problem is know as Clock angle problem where we need to find angle between hands of an analog clock at a given time.
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 »
You are given a function rand(a, b) which generates equiprobable random numbers between [a, b] inclusive. Generate 3 numbers x, y, z with probability P(x),… Read More »
Given a polynomial of the form cnxn + cn-1xn-1 + cn-2xn-2 + … + c1x + c0 and a value of x,
We can use a for loop to find sum.
Following is simple program to print first n Fibonacci numbers. Recommended: Please solve it on “PRACTICE ” first, before moving on to the solution. Output:… Read More »
Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is… Read More »
LCM (Least Common Multiple) of two numbers is the smallest number which can be divided by both numbers.
GCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them.
Given an integer n, write a function that returns count of trailing zeroes in n!.
Catalan numbers are a sequence of natural numbers that occurs in many interesting counting problems like following.
Given a positive integer n, generate all possible unique ways to represent n as sum of positive integers.
Given two integers, write a function to multiply them without using multiplication operator.
Given a number ‘n’, how to check if n is a Fibonacci number. First few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8,… Read More »