Senin, 24 Mei 2010

Script Bash untuk Bilangan Prima

#!/bin/bash

clear
echo -n "Masukkan Angka Awal:"
read aa
echo -n "Masukkan Angka Akhir:"
read ak
hitung()

{

local count=0

for a in `factor $1`

do

let count++

done

if [ $count -le 2 ]

# then echo "$1 bukan bilangan prima"
then
echo "$1 bilangan prima"

fi

}

for angka in `seq $aa $ak`
do
hitung $angka;
done

0 komentar: