fork download
  1. USING: io kernel math math.parser ;
  2.  
  3. IN: factorial-example
  4.  
  5. : modulo ( n -- n! )
  6. dup
  7. 2
  8. /
  9. 2
  10. *
  11. =
  12. [ 1 ]
  13. [ 0 ]
  14. if ;
  15.  
  16. : bin ( n -- )
  17. dup
  18. 0 =
  19. [ drop ]
  20. [ dup
  21. modulo
  22. swap
  23. -1
  24. shift
  25. bin
  26. number>string print
  27. ]
  28. if ;
  29.  
  30.  
  31. ! readln string>number
  32. ! bin
  33. 1
  34. mod
  35.  
  36.  
Runtime error #stdin #stdout 0.2s 163968KB
stdin
4
stdout
Data stack underflow