【bash学習008】練習:特定のモジュール演算を満たす整数を見つける

3602 ワード

タイトル:1-1000の中から、1つの数iを探し出して、型5余3、型7余4、型9余5を満たします.
#!/bin/bash



#  find the value (from 1 to 1000) ,which mod5=3,mod7=4,mod9=5.

#

##############################################################

#

#           write by xy

#           2013.4.13

#############################################################

MAX=1000      # if MAX=156, will not find this style value



for (( i=1;i<="$MAX";i++ ))

do

        if  (( i % 5 !=  3 )) # find this value which mod 5 equal to 3

        then

                continue

        fi



        if  (( i % 7 != 4 ))

        then

                continue

        fi



        if  (( i %9 != 5 ))

        then

                continue

        fi



        echo "$i is what i want fo find"

        exist_num="$?"    # save the above statment exit status

        break

done



if [ ! $exist_num ]

then

        echo "does not exist this style number!"

fi



exit $?

 
 
 
コードが腐っています.牛が見たら、アドバイスをしてください.アドバイスをもらいたいです.