Lazy Caterer's sequence

Problem Given a circular (or regular polygon) cake and a knife by which you can only cut vertically, find the maximum number of pieces of cake you can get by making n cuts. Write a program to do that. Solution The solution to this is very simple, if you know mathematics. :P Number of pieces p p = ( n^2+n+2)/2 p = C(n+1,2) + 1 ``` More on wikipedia - [http://en. [Read More]

How to check whether a given number n belongs to fibanocii series?

The standard way (other than generating up to N) is to check if (5N2+4) or (5N2−4) is a perfect square.

 Had discussion with my friend, on this and hence I thought its a good information to share via blog.

More - 

http://math.stackexchange.com/questions/9999/checking-if-a-number-is-a-fibonacci-or-not

Basic Mathematics in Algorithms

Recurrence Relations Recurrence relations often arise in calculating the time and space complexity of algorithms. The amount of time (or space) that a program takes, Tk, is typically a function of the size, k, of the input data. A recurrence relation arises when Tk is some function of Tk’ for k’ Logarithmic Complexity The following recurrence **Tk = Tk/2 + a if k!=1 = b if k=1 ** has the solution [Read More]