Caydenz

Challenge

Apr 5th, 2016
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. def a(number, start):
  2.     bool = True
  3.     if start < number:
  4.         if number % start == 0:
  5.             bool = False
  6.         else:
  7.             bool = a(number, start + 1)
  8.     return bool
  9.  
  10. def b(n1, n2):
  11.     result = 0
  12.     if n2 > n1:
  13.         pass
  14.     else:
  15.         if n2 == 0:
  16.             result = 1
  17.         else:
  18.             if n2 == n1:
  19.                 result = 1
  20.             else:
  21.                 result = b(n1 - 1, n2 - 1)
  22.                 result += b(n1 - 1, n2)
  23.     return result
  24.    
  25. def c(nr):
  26.     result = 0
  27.     if nr != 0:
  28.         if nr < 3:
  29.             result = 1
  30.         else:
  31.             result = c(nr - 1)
  32.             result += c(nr - 2)
  33.             result += 1
  34.     result = result % 987654321
  35.     return result
  36.    
  37. def X(nr):
  38.     result = c(nr)
  39.     if result % 3 == 0:
  40.         temp = Y(nr - 1)
  41.         result = result + 1
  42.     else:
  43.         temp = Z(nr - 1)
  44.     result = temp + result
  45.     return result
  46.    
  47. def Y(nr):
  48.     result = b(nr, 5)
  49.     if result % 7 == 0:
  50.         temp = X(nr - 1)
  51.         result = result + 1
  52.     else:
  53.         temp = Z(nr - 1)
  54.     result = temp + result
  55.     return result
  56.    
  57. def Z(nr):
  58.     result = 0
  59.     bool = True
  60.     if nr > 1 :
  61.         bool = a(nr, 2)
  62.         if bool:
  63.             result = X(nr - 1) + 1
  64.         else:
  65.             result = Y(nr - 1)            
  66.     return result
  67.  
  68. number = 8283840
  69. print Z(number)
Add Comment
Please, Sign In to add comment