fork download
  1. USING: formatting io kernel locals math math.functions math.parser ;
  2. IN: math
  3. MATH: mod ( x y -- z ) foldable flushable
  4.  
  5. IN: template
  6.  
  7. : sum-it ( n -- answer )
  8. dup 0 = ! if
  9. [ ] ! zero in stack
  10. [ 1 - ! decrease count by one
  11. readln string>number ! read next a_i
  12. swap ! a_i (n - 1) in stack
  13. sum-it + ! recur
  14. ]
  15. if ;
  16.  
  17. readln string>number
  18. 2
  19. mod
  20. number>string print
Success #stdin #stdout 1.38s 164864KB
stdin
5
stdout
1