$0=N+1 # $0,$1 := (N+1),(N/K); $1=N/K $2=N*N # $2,$3 := (N*N),(K*N); $3=K*N while$0>$1 # while $0>$1: $0=$1 # $0,$1 := $1,(($1*$1+N*N)/(2*$1+K*N)); $4=$1*$1 $1=2*$1 $4=$4+$2 $1=$1+$3 $1=$4/$1 end # end ifM>0 $0=$0+1 end $2=K*$0 # $2 := K*$0+1-M; $2=$2+1 $2=$2-M $3=$3+1 # $3 := K*N+1-M; $3=$3-M $1=$3/$2 while$1==K # while $3/$2==K: $4=$3%$2 # $2,$3 := $3%$2,$2; $3=$2 $2=$4 $5=1-$5 # $5 := 1-$5; if$2==0 # if $2==0: $2=1 # $2,$3 := 1,K+1; $3=K+1 end # end $1=$3/$2 end # end if$5==1 # if $5==1 and $1>K: if$1>K $0=$0-1 # $0 := $0-1; end end # end if$5==0 # if $5==0 and $1