>>101207435
Modulo was just an example of what I consider a primitive, not something I used in the program
Primes { # from rosetta code
x≤2 ? 0 ; # No primes below 2
p S√nx # Initial primes by recursion
b 2≤n # Initial sieve: no 0 or 1
E {∘((x×x+⊢)=)n} # Multiples of x under n, starting at x×x
/ b E⊸{0¨(w⊸⊏)x}´ p # Cross them out
}
below is from ~2 years ago 2021-12-29 20:53:04.007008875 5 minutes after I learned about arrays in c
main ()
{
int a [ 10000 ];
for ( int i = 0; i < 10000; i++ ) {
a [ i ] = 1;
}
for ( int i = 2; i <= 100; i++ ) {
if ( a [ i ] ) {
for ( int j = i * i ; j <= 10000 ; j = j + i ) {
a [ j ] = 0;
}
}
}
int i = 2;
while ( i < 10000 ) {
if ( a [ i ]) {
printf ( "%d\n", i * a [ i ] );
}
i++;
}
}
If the goal of a programming language is to implement a correct algorithm then c clears
In your example you use
~19 language primitives in 7 lines
this c code uses ~13 (including types) at most and they are generally much simpler than a bqn (>30) or lisp primitive, you don't get much more complicated than printf and for. You don't want to see what a library version of bqn's or lisps soe looks like.
No doubt someone better at c could improve this code too.