Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. x = 10
  2. y = 25
  3. z = 15
  4.  
  5. w = 40
  6. variantsQuantity = 0
  7.  
  8.  
  9. def calcRes(x, y, z, variantsQuantity):
  10.     res = 0
  11.     if w%x == 0:
  12.         for el in range(int(w/x)):
  13.             res+=x
  14.             if w%res == 0 and res<=w:
  15.                 variantsQuantity += 1
  16.             elif res>w:
  17.                 res = 0
  18.            
  19.             if w%y == 0:
  20.                 for el in range(int(w/y)):
  21.                     res+=y
  22.                     if w%res == 0 and res<=w:
  23.                         variantsQuantity += 1
  24.                     elif res>w:
  25.                         res = 0
  26.            
  27.             if w%z == 0:
  28.                 for el in range(int(w/z)):
  29.                     res+=z
  30.                     if w%res == 0 and res<=w:
  31.                         variantsQuantity += 1
  32.                     elif res>w:
  33.                         res = 0
  34.     return variantsQuantity
  35.  
  36.  
  37. variantsQuantity = calcRes(x, y, z, variantsQuantity)
  38. print variantsQuantity
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement