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