primes.bf 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. ===================================================================
  2. ======================== OUTPUT STRING ============================
  3. ===================================================================
  4. >++++++++[<++++++++>-]<++++++++++++++++.[-]
  5. >++++++++++[<++++++++++>-]<++++++++++++++.[-]
  6. >++++++++++[<++++++++++>-]<+++++.[-]
  7. >++++++++++[<++++++++++>-]<+++++++++.[-]
  8. >++++++++++[<++++++++++>-]<+.[-]
  9. >++++++++++[<++++++++++>-]<+++++++++++++++.[-]
  10. >+++++[<+++++>-]<+++++++.[-]
  11. >++++++++++[<++++++++++>-]<+++++++++++++++++.[-]
  12. >++++++++++[<++++++++++>-]<++++++++++++.[-]
  13. >+++++[<+++++>-]<+++++++.[-]
  14. >++++++++++[<++++++++++>-]<++++++++++++++++.[-]
  15. >++++++++++[<++++++++++>-]<+++++++++++.[-]
  16. >+++++++[<+++++++>-]<+++++++++.[-]
  17. >+++++[<+++++>-]<+++++++.[-]
  18. ===================================================================
  19. ======================== INPUT NUMBER ============================
  20. ===================================================================
  21. + cont=1
  22. [
  23. - cont=0
  24. >,
  25. ======SUB10======
  26. ----------
  27. [ not 10
  28. <+> cont=1
  29. =====SUB38======
  30. ----------
  31. ----------
  32. ----------
  33. --------
  34. >
  35. =====MUL10=======
  36. [>+>+<<-]>>[<<+>>-]< dup
  37. >>>+++++++++
  38. [
  39. <<<
  40. [>+>+<<-]>>[<<+>>-]< dup
  41. [<<+>>-]
  42. >>-
  43. ]
  44. <<<[-]<
  45. ======RMOVE1======
  46. <
  47. [>+<-]
  48. ]
  49. <
  50. ]
  51. >>[<<+>>-]<<
  52. ===================================================================
  53. ======================= PROCESS NUMBER ===========================
  54. ===================================================================
  55. ==== ==== ==== ====
  56. numd numu teid teiu
  57. ==== ==== ==== ====
  58. >+<-
  59. [
  60. >+
  61. ======DUP======
  62. [>+>+<<-]>>[<<+>>-]<
  63. >+<--
  64. >>>>>>>>+<<<<<<<< isprime=1
  65. [
  66. >+
  67. <-
  68. =====DUP3=====
  69. <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<
  70. =====DUP2=====
  71. >[>>+>+<<<-]>>>[<<<+>>>-]<<< <
  72. >>>
  73. ====DIVIDES=======
  74. [>+>+<<-]>>[<<+>>-]< DUP i=div
  75. <<
  76. [
  77. >>>>>+ bool=1
  78. <<<
  79. [>+>+<<-]>>[<<+>>-]< DUP
  80. [>>[-]<<-] IF i THEN bool=0
  81. >>
  82. [ IF i=0
  83. <<<<
  84. [>+>+<<-]>>[<<+>>-]< i=div
  85. >>>
  86. - bool=0
  87. ]
  88. <<<
  89. - DEC i
  90. <<
  91. -
  92. ]
  93. +>>[<<[-]>>-]<<
  94. >[-]< CLR div
  95. =====END DIVIDES====
  96. [>>>>>>[-]<<<<<<-] if divides then isprime=0
  97. <<
  98. >>[-]>[-]<<<
  99. ]
  100. >>>>>>>>
  101. [
  102. -
  103. <<<<<<<[-]<<
  104. [>>+>+<<<-]>>>[<<<+>>>-]<<<
  105. >>
  106. ===================================================================
  107. ======================== OUTPUT NUMBER ===========================
  108. ===================================================================
  109. [>+<-]>
  110. [
  111. ======DUP======
  112. [>+>+<<-]>>[<<+>>-]<
  113. ======MOD10====
  114. >+++++++++<
  115. [
  116. >>>+<< bool= 1
  117. [>+>[-]<<-] bool= ten==0
  118. >[<+>-] ten = tmp
  119. >[<<++++++++++>>-] if ten=0 ten=10
  120. <<- dec ten
  121. <- dec num
  122. ]
  123. +++++++++ num=9
  124. >[<->-]< dec num by ten
  125. =======RROT======
  126. [>+<-]
  127. < [>+<-]
  128. < [>+<-]
  129. >>>[<<<+>>>-]
  130. <
  131. =======DIV10========
  132. >+++++++++<
  133. [
  134. >>>+<< bool= 1
  135. [>+>[-]<<-] bool= ten==0
  136. >[<+>-] ten = tmp
  137. >[<<++++++++++>>>+<-] if ten=0 ten=10 inc div
  138. <<- dec ten
  139. <- dec num
  140. ]
  141. >>>>[<<<<+>>>>-]<<<< copy div to num
  142. >[-]< clear ten
  143. =======INC1=========
  144. <+>
  145. ]
  146. <
  147. [
  148. =======MOVER=========
  149. [>+<-]
  150. =======ADD48========
  151. +++++++[<+++++++>-]<->
  152. =======PUTC=======
  153. <.[-]>
  154. ======MOVEL2========
  155. >[<<+>>-]<
  156. <-
  157. ]
  158. >++++[<++++++++>-]<.[-]
  159. ===================================================================
  160. =========================== END FOR ===============================
  161. ===================================================================
  162. >>>>>>>
  163. ]
  164. <<<<<<<<
  165. >[-]<
  166. [-]
  167. <<-
  168. ]
  169. ======LF========
  170. ++++++++++.[-]