Advertisement
Guest User

Problem I

a guest
Mar 18th, 2012
226
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. USING: io kernel math math.parser strings sequences locals ascii ;
  2.  
  3. IN: template
  4.  
  5. :: test ( out d n -- a b c )
  6.  
  7. n 1 =
  8. [ out d n ]
  9. [
  10. n
  11. d
  12. mod 0 =
  13. [
  14. out 1 +
  15. d
  16. n d /
  17. ]
  18. [ out d 1 + n ]
  19. if
  20.  
  21. test
  22.  
  23. ]
  24. if ;
  25.  
  26. :: testb ( out n -- a b )
  27.  
  28. n length 0 =
  29. [ out n ]
  30. [
  31. 0
  32. 2
  33. n string>number
  34. test
  35. drop drop
  36. 1 -
  37. out +
  38.  
  39. n 1 tail
  40. testb
  41.  
  42. ]
  43. if ;
  44.  
  45.  
  46. 0
  47. readln
  48. testb
  49.  
  50. drop
  51. 0 =
  52. [ "YES" ]
  53. [ "NO "]
  54. if
  55.  
  56. print
Advertisement
RAW Paste Data Copied
Advertisement