Category Archives: Algorithm

Fibonacci in Python

# Fibonacci numbers moduledef fib(n): # write Fibonacci series up to n a, b = 0, 1 while b < n: #print b, a, b = b, a+bdef fib2(n): # return Fibonacci series up to n result = [] a, … Continue reading

Posted in Algorithm | Leave a comment

Counting the number of "1" bits

Another “ridiculous” interview I had was when an interviewer asked me how to count the number of set bits in a 32-bit or 8-bit. I told him that there are various algorithms to do this, but the easiest way but … Continue reading

Posted in Algorithm | 1 Comment