I'm trying to "traduce" from Python (What is the best algorithm for checking if a number is prime?) to Shell Script. This is my idea (probably very silly code):
#!/bin/bash
prime (){
i=5
w=2
while [ `echo "$i*$i" | bc -l ` -le $n ]
    do
      if [ n % i -eq 0 ]
        then echo "$n is not prime"
      else
        i = i + w
        w = 6 - w
        echo "$n is prime"
    fi
done
}
echo "Test for knowing if a number is prime or not."
sleep 2
echo "Enter the number"
read n
if [ $n -eq 1 ]
   then echo "Number 1 is not prime"
elif [ $n -eq 2 ]
   then echo "Number two is prime"
elif [ $n -eq 3 ]
   then echo "Number three is prime"
else
   prime
fi
The problem is when i put any other number (4, 5, 6, ...) the program doesn't return back if $n is prime or not. If anyone can help me, I will be very grateful.
 
     
     
    