def sum(a, b):
  return a + b

def factR(n):
  if n > 1:
    return n * factR (n - 1)
  elif n == 1 or n == 0:
    return 1
  else:
    raise ArithmeticError("Factorial needs positive integers!")

print factR(1)
print factR(2)
print factR(4)

def mystery(n):
  for x in range(2, n):
    if n % x == 0:
      print n, 'equals ', x, ' * ', n/x
      break
  else:
    print n, ' passes the test!'

def factW(n):
  ans = 1
  while n > 1:
    ans *= n
    n -= 1
  return ans

def computeFacts(f, l):
  for x in l:
    print x, f(x)

def make_incrementor(n):
  def inc(x):
    return x + n
  return inc

def filterC(c, l):
  return [s for s in l if s[0] == c]

def div(n, d):
  if d == 0:
    return None
  else:
    return n/d

def testDiv():
  while True:
    n = float(raw_input("Please, enter the dividend: "))
    d = float(raw_input("Please, enter the divisor: "))
    a = div(n, d)
    if type(a) == type(None):
      break
    else:
      print a

def anagrams(s1, s2):
  if (len(s1) != len(s2)):
    return False
  else:
    table = {}
    for c in s1:
      if table.has_key(c):
        table[c] += 1
      else:
        table[c] = 1
    for c in s2:
      try:
        table[c] -= 1
        if table[c] == 0:
          table.pop(c)
      except KeyError:
        return False
    return True




