Horje
shell script to enter a number and check the number is perfect number or not Code Example
shell script to enter a number and check the number is perfect number or not
# !/bin/bash
echo "Enter a number"
read no  
i=1
ans=0
for i in 1 2 3 4 5 .. no  
do
        if [[ $((no%i)) -eq 0  ]]  
        then
            ans=$((ans + i))
            
fi
i=`expr $i + 1`
done

if [ $no -eq $ans ]  
then
        echo "$no is perfect"
        else
        echo "$no is NOT perfect"
fi




Shell

Related
awk convert first character to lowercase Code Example awk convert first character to lowercase Code Example
ubuntu 20 show dock only on hover Code Example ubuntu 20 show dock only on hover Code Example
how to use valet to share localhost url to outside Code Example how to use valet to share localhost url to outside Code Example
atom disable shelling out for environment Code Example atom disable shelling out for environment Code Example
i am not able to start bluetooth in ubantu Code Example i am not able to start bluetooth in ubantu Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10