templates/bash/soe-bash

20 lines
294 B
Plaintext
Raw Normal View History

2023-02-08 12:07:14 -05:00
#!/usr/bin/env bash
read num
echo
nums=()
for i in `seq 2 $num`; do
nums+=($i)
done
while [ -n "$nums" ]; do
prime=${nums[0]}
echo $prime
nums_=()
for elem in "${nums[@]}"; do
[ $(( $elem % $prime )) -eq 0 ] || nums_+=($elem)
done
nums=(${nums_[@]})
done