style: modify the output of scripts
Instead of separating output primes by newline, the scripts now separate by spaces.
This commit is contained in:
parent
0e55a43863
commit
a3b53b180c
|
@ -13,10 +13,12 @@ unset nums[-1]
|
|||
|
||||
while [ -n "$nums" ]; do
|
||||
prime=${nums[0]}
|
||||
echo $prime
|
||||
echo -n "$prime "
|
||||
nums_=()
|
||||
for elem in "${nums[@]}"; do
|
||||
[ $(( $elem % $prime )) -eq 0 ] || nums_+=($elem)
|
||||
done
|
||||
nums=(${nums_[@]})
|
||||
done
|
||||
|
||||
echo
|
||||
|
|
|
@ -7,7 +7,7 @@ set nums (seq 2 $num)[..-2]
|
|||
|
||||
while test -n "$nums"
|
||||
set prime $nums[1]
|
||||
echo $prime
|
||||
echo -n "$prime "
|
||||
|
||||
set -e nums_
|
||||
for elem in $nums
|
||||
|
@ -15,3 +15,5 @@ while test -n "$nums"
|
|||
end
|
||||
set nums $nums_
|
||||
end
|
||||
|
||||
echo
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
|
||||
def sieve_of_eratosthenes(n):
|
||||
nums = list(range(2, n))
|
||||
while nums:
|
||||
|
@ -11,7 +10,8 @@ def main():
|
|||
num = int(input("Primes up to: "))
|
||||
print()
|
||||
for i in sieve_of_eratosthenes(num):
|
||||
print(i)
|
||||
print(i, end=" ")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue