Вопрос по shell, bash – Ошибка сценария Bash: [i: команда не найдена

2

Error: User Rate Limit Exceeded

echo Enter num
read n
i=2
j=2

for(( i=2; i <= n; i++ ))
do

for(( j=2; j < i-1; j++ ))
do

if [i % j == 0];
then
break
fi


if [i == j];
then
echo "  $i"
fi
done
done

Error: User Rate Limit Exceeded

Enter num
20
prime.sh: line 12: [i: command not found
prime.sh: line 18: [i: command not found
prime.sh: line 12: [i: command not found
prime.sh: line 18: [i: command not found
 .
 .
 .

Error: User Rate Limit Exceeded

read -p "Enter a  number : " n
i=2
j=2
for(( i=2; i <= n; i++ ))
do
    for(( j=2; j <= i-1; j++ ))
    do
        if [ $(( i % j )) == 0 ]
        then
            break
        fi
        if [ i == j ]
        then
            echo "  $i"
        fi
    done
done

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded$Error: User Rate Limit Exceeded Daniel Kamil Kozar
Error: User Rate Limit Exceededif [i % j == 0]Error: User Rate Limit Exceededif [i == j]Error: User Rate Limit Exceededif [ i % j == 0 ]Error: User Rate Limit Exceededif [ i == j ]Error: User Rate Limit Exceededif [ i % j == 0 ] Roger That
Error: User Rate Limit Exceeded(())Error: User Rate Limit Exceededif (( i % j == 0 )); thenError: User Rate Limit Exceededif (( i == j )); thenError: User Rate Limit Exceededif [[ $string1 == $string2 ]]Error: User Rate Limit Exceeded Dennis Williamson
jError: User Rate Limit ExceedediError: User Rate Limit Exceededi. chepner
Error: User Rate Limit Exceeded[i % j == 0]Error: User Rate Limit Exceeded[ i % j == 0 ]. Daniel Kamil Kozar

Ваш Ответ

4   ответа
0

[test[]

if test $((i % j)) = 0; then
   break
fi
Error: User Rate Limit Exceeded/bin/testError: User Rate Limit Exceeded/usr/bin/testError: User Rate Limit Exceeded/bin/[Error: User Rate Limit Exceeded/usr/bin/[Error: User Rate Limit Exceeded[Error: User Rate Limit Exceeded]Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded Roger That
2

[[

if (( i % j == 0 )).

Error: User Rate Limit Exceeded Roger That
Error: User Rate Limit Exceeded[ / testError: User Rate Limit Exceededif [ $i == $j ]; then ..; fi;Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded==Error: User Rate Limit Exceeded-eqError: User Rate Limit Exceededif [ $i -eq $j ]
Error: User Rate Limit ExceededisError: User Rate Limit Exceeded(( i % j == 0 ))Error: User Rate Limit Exceeded
1

if [i % j == 0];Error: User Rate Limit Exceededif [ i % j == 0 ];

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceededif [ $i % $j == 0] Roger That
0

#!/bin/bash
#
# primes
#
read -p "Enter a  number: " n
i=2

for (( i=2; i <= n; i++ ))
do
    for (( j=2; j*j < i; j++ ))
    do
        if ((i % j == 0))
        then
            echo "no prime, $i divider: "$j
            break
        fi
    done
done
updated, after realizing (thanks Will Ness), that all primes up to INPUT are searched.

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded

Похожие вопросы