Untitled

 avatar
user_9935402641
plain_text
2 years ago
947 B
7
Indexable
Never
QUESTION - 1

echo "Enter a composite number : "
read a
count=0
echo -n "5 prime numbers are : "
for (( i=a+1; ;i++ ))
do
    var=$i
    flag=0
    for (( j=2; j<i/2+1; j++ ))
    do
        if (( $var % $j == 0 ))
        then 
            flag=1
            break
        fi
    done
    if (( $flag == 0 ))
    then
        echo -n "$i "
        count=$((count+1))
    fi
    if (( $count == 5 ))
    then
        break
    fi
done





QUESTION - 2

a=0
b=9
for (( i=1; i<=5; i++ ))
do 
    for (( j=1; j<=9; j++ ))
    do
        if (( $j>=$i && $j<=10-$i ))
        then
            if (( $i % 2 != 0 ))
            then 
                echo -n "$a "
            else
                echo -n "$b "
            fi
        else
            echo -n "  "
        fi
    done
    echo ""
    if (( $i % 2 != 0 ))
    then
        a=$((a+1))
    else
        b=$((b-1)) 
    fi
done