fork(5) download
  1. w={0:"zero",1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven",8:"eight",9:"nine",10:"ten",11:"eleven",12:"twelve",13:"thirteen",14:"fourteen",15:"fifteen",16:"sixteen",17:"seventeen",18:"eighteen",19:"nineteen",20:"twenty",30:"thirty",40:"forty",50:"fifty",60:"sixty",70:"seventy",80:"eighty",90:"ninety"}
  2. s=""
  3. def i(n):
  4. global s
  5. e=""
  6. if n==0:e="zero"
  7. o=n%10
  8. t=n%100
  9. h=n/100%10
  10. th=n/1000
  11. if th:
  12. e+=i(th)
  13. e+='thousand'
  14. if h:
  15. e+=w[h]
  16. e+='hundred'
  17. if t:
  18. if t<20 or o==0:
  19. e+=w[t]
  20. else:
  21. e+=w[t-o]
  22. e+=w[o]
  23. if n==4:s+="4 is the magic number";print s
  24. else: s+="%d is %d and "%(n,len(e));i(len(e))
  25. In=input()
  26. i(In)
Success #stdin #stdout 0.01s 8976KB
stdin
5
stdout
5 is 4 and 4 is the magic number