SHARE
TWEET

assignment4

sevenish Dec 8th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ::  the sum of the multiples of 3 or 5 below 1.000 is 233.168
  2. ::  which can be confirmed by running the below %say generator
  3. ::  
  4. |%
  5. ++  thousand  (sumthreefive 1.000)
  6. ++  sumthreefive
  7.     |=  end=@ud
  8.     =/  count=@ud  1
  9.     =/  sum=@ud  0
  10.     |-
  11.     ^-  @ud
  12.     ?:  =(end count)
  13.         sum
  14.     ?:  ?|  =(0 (mod count 3))
  15.             =(0 (mod count 5))
  16.         ==
  17.         $(count (add 1 count), sum (add sum count))
  18.     $(count (add 1 count))
  19. --
  20. :-  %say
  21. |=  *
  22. :-  %noun
  23. thousand
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top