Advertisement
keatondunsford

Untitled

Oct 17th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. :: Project Euler 5
  2. :: https://projecteuler.net/problem=5
  3. ::
  4. :: run in dojo with:
  5. :: ~your-urbit:dojo/examples> +project-euler/p5
  6. ::
  7. :::: /===/gen/project-euler/p5/hoon
  8. ::
  9. !:
  10. ::
  11. :- %say |= *
  12. :- %noun
  13. =< (lcm 20)
  14. ::
  15. !.
  16. ::
  17. |%
  18. ++ sieve :: given a, check if a%div==0, incrementing div until it's lim, or .y
  19. |= [a=@u lim=@u]
  20. =+ div=1
  21. |- ^- @f
  22. ?: =(div lim)
  23. .y
  24. ?: =((mod a div) 0)
  25. $(div +(div))
  26. .n
  27. ::
  28. ++ lcm :: check if sieve returns .y, incrementing the number until it does
  29. |= a=@u
  30. =+ b=a
  31. |- ^- @u
  32. ?: =((sieve b a) .y)
  33. b
  34. $(b (add b a))
  35. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement