# Category Archives: Algorithm

## Sum of divisors of factorial of a numberJune 7, 2017

Given a number n, we need to calculate the sum of divisors of factorial of the number. Examples: Input : 4 Output : 60 Factorial… Read More »

## Bit Tricks for Competitive Programming

In competitive programming or in general some problems seems difficult but can be solved very easily with little bit magic. We have discussed some tricks… Read More »

## Multiple of x closest to nJune 6, 2017

Given two numbers n and x, we need to calculate the smallest value of x that is closest to given number n. Examples: Input :… Read More »

## Combinations where every element appears twice and distance between appearances is equal to the value

Given a positive number n, we need to find all the combinations of 2*n elements such that every element from 1 to n appears exactly… Read More »

## Ways to sum to N using array elements with repetition allowed

Given a set of m distinct positive integers and a value ‘N’. The problem is to count the total number of ways we can form… Read More »

## Closest (or Next) smaller and greater numbers with same number of set bitsJune 5, 2017

Given a positive integer n, print the next smallest and the previous largest number that have the same number of 1 bits in their binary… Read More »

## is_permutation() in C++ and its application for anagram searchJune 4, 2017

is_permutations() is used to check if two containers like string and vector are permutation of each other. It accepts three parameters, the first two parameters… Read More »

## Minimum revolutions to move center of a circle to a target

Given a circle of radius r and center in point(x1, y1) and given a point(x2, y2). The task is move center of circle from given… Read More »

## Automorphic Number

Given a number N, the task is to check whether the number is Automorphic number or not. A number is called Automorphic number if and… Read More »

## Interesting facts about Fibonacci numbers

We know Fibonacci number, Fn = Fn-1 + Fn-2. First few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55,… Read More »

## Express a number as sum of consecutive numbers

Given a number N, write a function to express N as sum of two or more consecutive positive numbers. If there is no solution, output… Read More »

## Find n-th element in a series with only 2 digits (4 and 7) allowed

Consider a series of numbers composed of only digits 4 and 7. First few numbers in the series are 4, 7, 44, 47, 74, 44744,..… Read More »

## Sequences of given length where every element is more than or equal to twice of previous

Given two integers m & n, find the number of possible sequences of length n such that each of the next element is greater than… Read More »

## Maximum sum of distinct numbers such that LCM of these numbers is N

Given a positive number N. The task is to find maximum sum of distinct numbers such that the LCM of all these numbers is equal… Read More »

## Perfect cubes in a rangeJune 3, 2017

Given two given numbers a and b where 1 <= a <= b, find perfect cubes between a and b (a and b inclusive). Examples:… Read More »