more examples
All checks were successful
/ test (push) Successful in 47s

This commit is contained in:
Neemek 2026-07-15 21:50:23 +02:00
parent 9e90bdfc33
commit ca0031431d
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E
19 changed files with 287 additions and 0 deletions

40
examples/bad.ang Normal file
View file

@ -0,0 +1,40 @@
import "lib/math.ang"
primes := [2]
func is_prime(x: number) boolean {
i := 0
while i < primes.length() && primes.at(i)*primes.at(i) < x {
if mod(x, primes.at(i)) == 0 {
return false
}
i = i + 1
}
return true
}
n := 1
max := 100000
while n < max {
n = n + 2
if is_prime(n) {
primes.append(n)
# Update counter
print(char(0x0D))
print(str(n))
print("/")
print(str(max))
print(char(0x09))
print(str(roundd(n/max*100, 2)))
print("%")
print(char(0x09))
print(str(primes.length()))
print(" primes")
}
}
write(str(primes))