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