# Category Archives: Mathematical

## To check a number is palindrome or not without using any extra spaceAugust 28, 2017

Given a number ‘n’ and our goal is to find out it is palindrome or not without using any extra space. We can’t make a… Read More »

## Find smallest permutation of given numberAugust 25, 2017

Given a long integer, return the smallest(magnitude) integer permutation of that number. Examples: Input : 5468001 Output : 1004568 Input : 5341 Output : 1345… Read More »

## Analysis of Different Methods to find Prime Number in PythonAugust 24, 2017

If you participate in the competitive programming, you might be familiar with the fact that questions related to Prime numbers are one of the choices… Read More »

## Distributing M items in a circle of size N starting from K-th positionAugust 23, 2017

M items are to be delivered in a circle of size M. Find the position where the M-th item will be delivered if we start… Read More »

## Check whether right angled triangle is valid or not for large sides

Given three integers a, b and c as triplets. Check if it is possible to make right angled triangle or not. Print Yes if possible,… Read More »

## An interesting solution to get all prime numbers smaller than nAugust 20, 2017

This approach is based on Wilson’s theorem and using the fact that factorial computation can be done easily using DP Wilson theorem says if a… Read More »

## Prove that atleast one of three consecutive even numbers is divisible by 6August 19, 2017

Given three consecutive even numbers. Prove mathematically that atleast one of them is divisible by 6. Examples: Input : {2, 4, 6} Output : 6… Read More »

## Find whether a given integer is a power of 3 or notAugust 16, 2017

Given a positive integer, write a function to find if it is a power of three or not. Examples: Input : 3 Output :Yes Input… Read More »

## Estimating the value of Pi using Monte CarloAugust 15, 2017

Monte Carlo estimation Monte Carlo methods are a broad class of computational algorithms that rely on repeated random sampling to obtain numerical results. One of… Read More »

## Find the number closest to n and divisible by mAugust 14, 2017

Given two integers n and m. The problem is to find the number closest to n and divisible by m. If there are more than… Read More »

## Check if a given number is Pronic

The numbers that can be arranged to form a rectangle are called Rectangular Numbers (also known as Pronic numbers). The first few Pronic numbers are:… Read More »

## Simulated AnnealingAugust 11, 2017

Problem : Given a cost function f: R^n –> R, find an n-tuple that minimizes the value of f. Note that minimizing the value of… Read More »

## Count ways to express a number as sum of consecutive numbersAugust 9, 2017

Given a number N, find the number of ways to represent this number as a sum of 2 or more consecutive natural numbers. Examples: Input… Read More »

## Find minimum sum of factors of numberAugust 8, 2017

Given a number, find minimum sum of its factors. Examples: Input : 12 Output : 7 Explanation: Following are different ways to factorize 12 and… Read More »

## Minimum number with digits as 4 and 7 only and given sumAugust 6, 2017

Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. What minimum lucky number has the sum of… Read More »