Tag Archives: python

power function in O(n) time, algorithm plus implementation in python

Algorithm number 1.   Algorithm powerOf(x,n)         Input: integer n, non negative integer x         Output : x to the power of n         if n = 0              return 1         m ← 0         while n > 0 … Continue reading

Posted in Code samples | Tagged | Leave a comment

Find the factorial : Python

def factorial(n): """ Returns the factorial of an integer Author: http://www.victorbyte.net """ if n == 0: return 1; elif n > 0: return n * factorial(n – 1);

Posted in Code samples | Tagged | Leave a comment

Remove duplicate characters: python

Python is a great language for text formatting. The trivial functions below are not fully representative of the things one can do in Python, however for a beginner they are sufficient. For further reading I suggest one looks at Python's … Continue reading

Posted in duplicate | Tagged | Leave a comment