Kiana Sheibani
a3b53b180c
Instead of separating output primes by newline, the scripts now separate by spaces.
20 lines
293 B
Fish
Executable file
20 lines
293 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 -n "$prime "
|
|
|
|
set -e nums_
|
|
for elem in $nums
|
|
test (math $elem % $prime) -eq 0 || set -a nums_ $elem
|
|
end
|
|
set nums $nums_
|
|
end
|
|
|
|
echo
|