# Category Archives: Mathematical

## Check if a number is multiple of 5 without using / and % operatorsSeptember 2, 2011

Given a positive number n, write a function isMultipleof5(int n) that returns true if n is multiple of 5, otherwise false. You are not allowed to use % and / operators.

## Program for Fibonacci numbersMarch 6, 2011

The Fibonacci numbers are the numbers in the following integer sequence.

## Print all combinations of balanced parenthesesSeptember 24, 2010

Write a function to generate all possible n pairs of balanced parentheses.

## Write you own Power without using multiplication(*) and division(/) operatorsSeptember 12, 2010

Method 1 (Using Nested Loops) We can calculate power by using repeated addition.

## Print all combinations of points that can compose a given numberMay 3, 2010

You can win three kinds of basketball points, 1 point, 2 points, and 3 points. Given a total score n, print out all the combination to compose n.

## Multiply two integers without using multiplication, division and bitwise operators, and no loopsMarch 11, 2010

By making use of recursion, we can multiply two integers with the given constraints. To multiply x and y, recursively add x y times. Time Complexity: O(y) where y is the second argument to function multiply(). Russian Peasant (Multiply two numbers using bitwise operators) Please write comments if you find any of the above code/algorithm… Read More »

## Babylonian method for square rootDecember 20, 2009

Algorithm: This method can be derived from (but predates) Newton–Raphson method.

## Write a program to add two numbers in base 14August 8, 2009

Asked by Anshya. Below are the different ways to add base 14 numbers.

## Lucky NumbersAugust 6, 2009

Lucky numbers are subset of integers. Rather than going into much theory, let us see the process of arriving at lucky numbers,

## Write a program to print all permutations of a given stringAugust 2, 2009

A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with S itself. A string of length n has n! permutation.

## Power SetJune 22, 2009

Power Set Power set P(S) of a set S is the set of all subsets of S. For example S = {a, b, c} then P(s) = {{}, {a}, {b}, {c}, {a,b}, {a, c}, {b, c}, {a, b, c}}. If S has n elements in it then P(s) will have 2^n elements