Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. :: Creates a gate that takes any atom, called n
  2. ::
  3. |= n=@
  4. :: Runs the goldbach arm with n as the subject
  5. ::
  6. =< (goldbach n)
  7. :: Declares a new core,
  8. ::
  9. |%
  10. :: with an arm called prime.
  11. ::
  12. ++ prime
  13. :: prime contains a gate that takes any atom and calls it n
  14. :: it determines if n is a prime number or not.
  15. ::
  16. |= n=@
  17. :: Casts the gate's result to a flag
  18. ::
  19. ^- ?
  20. :: If n is less than 2 then this evaluates to no
  21. ::
  22. ?: (lth n 2) |
  23. :: if n is less than 2 then yes
  24. ::
  25. ?: (lth n 4) &
  26. :: Adds 2 to the subject as i
  27. ::
  28. =/ i=@ 2
  29. :: Adds 2 to the subject as j
  30. ::
  31. =/ j=@ 2
  32. :: Creates a trap that typecasts to a flag
  33. ::
  34. |- ^- ?
  35. :: if i times j euqals n then no
  36. ::
  37. ?: =((mul i j) n) |
  38. :: and if j equals n divided by 2 then yes
  39. ::
  40. ?: =(j (div n 2)) &
  41. :: is i times j greater than n?
  42. ::
  43. ?: (gth (mul i j) n)
  44. :: If so, then recurse with i set to 2 and j incremented
  45. ::
  46. $(i 2, j +(j))
  47. :: if not, then recurse with i incremented
  48. $(i +(i))
  49. :: this is an arm called goldbach.
  50. ::
  51. ++ goldbach
  52. :: it has a gate that takes n, an atom
  53. ::
  54. |= n=@
  55. :: Typecasts the result to either a flag or a cell containing two atoms and a flag
  56. ::
  57. ^- ?(? [[@ @] ?])
  58. :: if n is less than 4 or n divided by 2 has a remainder of 1,
  59. :: return a no flag as n isn't covered under the goldbach conjecture
  60. ::
  61. ?: |((lth n 4) =((mod n 2) 1)) |
  62. :: the subject now includes i, an atom with the value of 2,
  63. ::
  64. =/ i=@ 2
  65. :: as well as j, the value of n minus 2
  66. ::
  67. =/ j=@ (sub n 2)
  68. :: A trap that typecasts to either a flag or a cell containing two atoms and a flag
  69. ::
  70. |- ^- ?(? [[@ @] ?])
  71. :: if i and j are prime then [[i j] no]
  72. :: [[i j] n] are the prime numbers that add up to n.
  73. :: no is added because the goldbach conjecture wasn't disproven
  74. ::
  75. ?: &((prime i) (prime j)) [[i j] |]
  76. :: if this isn't true then check to see if i + 2 = n
  77. :: if true then the goldbach conjecture was disproven, return yes
  78. ::
  79. ?: =((add 2 i) n) &
  80. :: if this isn't false, then recurse; incrememting i and decrememting j
  81. ::
  82. $(i +(i), j (dec j))
  83. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement