Sequence of primes by trial division: Difference between revisions
Content added Content deleted
m (Fixed insertion in wrong place.) |
(Added entry for language AsciiDots) |
||
Line 276: | Line 276: | ||
9: 23 |
9: 23 |
||
10: 29 |
10: 29 |
||
</pre> |
|||
=={{header|AsciiDots}}== |
|||
Program to generate all prime numbers up to the input (inclusive). This implementation is very inefficient currently since the primality test checks every number from 2 to N rather than checking up to the square root, excluding even numbers from the factor checks, etc. |
|||
<lang AsciiDots> |
|||
``warps |
|||
%$ABCPR |
|||
``outputs all primes up to and including the input |
|||
.-#?-A |
|||
B-P/$_#$_" "# |
|||
R-*~ |
|||
\/ |
|||
``primality test |
|||
/---------------*-\ |
|||
//-----------{*}*~-+\ |
|||
///--#1--\ /#1>/ \/ || |
|||
\\*/#2>*-\-~#0*>R || |
|||
/*>*+--++{%}/ \+>C || ``signal to C triggers next number |
|||
|\--/>-/| || || ``to be input from for loop |
|||
| /-~*--+-------^| || |
|||
| |[<]\ | */ || |
|||
| \-* | | | /--+/ |
|||
|/-[+]|[*]------+-<1#* |
|||
|\1#* \-+-------+----/ |
|||
| ~---* ^--\ |
|||
| \---/ | | |
|||
\------\ | | |
|||
/-----~\ /-----~#0/ |
|||
P*#2{<}/\-*#2{=}/ ``hardcode <=1 and 2 |
|||
\---/ \---/ |
|||
``for loop |
|||
``only outputs next number once C receives any input |
|||
.-\C#1-*--\ /--B |
|||
# /-{+}-+-*--\ |
|||
1 | /---+----~ |
|||
*->-*\ \---\| |
|||
A{+}>*{-}*-{>}+/ |
|||
//| \#0/ | |
|||
\{*}-------/ |
|||
</lang> |
|||
{{out}} |
|||
Output shown for input of 100 |
|||
<pre> |
|||
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 |
|||
</pre> |
</pre> |
||