$1=1 $2=N/K $2=$2+2 $8=N*N $9=K*N while$1<$2 $3=$1+$2 $3=$3+1 $3=$3/2 $5=$3+$9 $5=$5*$3 if$5>$8 $2=$3 $2=$2-1 end if$5<=$8 $1=$3 end end $1=$1+N return$1