Sequence of primes by trial division: Difference between revisions
Content added Content deleted
(→Fun With Lists: fix, simplify, massiv speed-up) |
(→bc: add) |
||
Line 547: | Line 547: | ||
280: 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 |
280: 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 |
||
</pre> |
</pre> |
||
=={{header|bc}}== |
|||
<syntaxhighlight lang="bc">l = 100 |
|||
a[0] = 2 |
|||
a[o = 1] = 3 |
|||
for (n = 5; n < l; n += 2) { |
|||
for (i = 1; n % (p = a[i]) != 0; ++i) { |
|||
if (p * p > n) { |
|||
a[++o] = n |
|||
break |
|||
} |
|||
} |
|||
} |
|||
for (i = 0; i <= o; ++i) a[i]</syntaxhighlight> |
|||
=={{header|Befunge}}== |
=={{header|Befunge}}== |