Question d’entretien chez Riverbed Technology

Factorial using recursion and iteration.Network protocols.

Réponse à la question d'entretien

Utilisateur anonyme

31 juill. 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))