#!/bin/bash ######################### # source-encoding >> UTF-8 # # 素因数分解 # author : 河合 佑太 # ########################## function solver1() { dividNum=2 targetNum=$1 echo -n ">> ${targetNum}: " targetSqrt=$(echo "sqrt($targetNum)" | bc) while [ $dividNum -le $targetSqrt ] do if [ 0 -eq `expr $targetNum % $dividNum` ]; then targetNum=`expr $targetNum / $dividNum` targetSqrt=$(echo "sqrt($targetNum)" | bc) echo -n " ${dividNum}" else dividNum=`expr $dividNum + 1` fi done if [ $targetNum != 1 ]; then echo -n " ${targetNum}" fi echo '' } #echo "What's the number?" #echo '?' #read readNum loop_c=1 #ここのループ回数を調節して各実験を行う while [ $loop_c != 10001 ] do solver1 $loop_c loop_c=`expr $loop_c + 1` done