Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. def d(x):
  2. while x > 9:
  3. x = sum(int(c) for c in str(x))
  4. return x
  5.  
  6. def count_failing_cases(n):
  7. total = 0
  8. for a in range(1, n+1):
  9. for b in range(1, n+1):
  10. for c in range(1, n+1):
  11. if d(a*b) == c and a*b != c:
  12. total += 1
  13. return total
  14.  
  15. for n in [4, 5]:
  16. print(f"count_failing_cases({n}) = {count_failing_cases(n)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement