employer cover photo
employer logo
employer logo

Riverbed Technology

Is this your company?

Riverbed Technology interview question

Factorial using recursion and iteration.Network protocols.

Interview Answer

Anonymous

31 Jul 2014

class Factorial: '''Calculate the n-th factorial via recursion and iteration method \ provided given number >= 0 ''' def __init__(self,n): self.n = n def byRecursion(self,n): if (n 1): ret = ret * n n = n - 1 return ret def prt(self): print 'by Recursion: ' + str(self.byRecursion(self.n)) print 'by Iteration: ' + str(self.byIteration(self.n))