templates/fish/nixpkgs/soe

18 lines
281 B
Fish
Executable file

#!/usr/bin/env fish
read -P "Primes up to: " num
echo
set nums (seq 2 $num)[..-2]
while test -n "$nums"
set prime $nums[1]
echo $prime
set -e nums_
for elem in $nums
test (math $elem % $prime) -eq 0 || set -a nums_ $elem
end
set nums $nums_
end