ifK<=63 ifK<=32 ifK<=16 ifK<=8 ifK<=4 if K == 1 # 701408733/433494437 == [0;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2] $0 = 267914296 $1 = 433494437 end if K == 2 # 1855077841/1311738121 == [0;2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2] $0 = 543339720 $1 = 1311738121 end if K == 3 # 2609758549/2003229469 == [0;3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] $0 = 606529080 $1 = 2003229469 end if K == 4 # 3672623806/2971215073 == [0;4,4,4,4,4,4,4,4,4,4,4,4,4,4,5] $0 = 701408733 $1 = 2971215073 end end ifK>=5 if K == 5 # 5030520053/4218173971 == [0;5,5,5,5,5,5,5,5,5,5,5,5,5,2] $0 = 812346082 $1 = 4218173971 end if K == 6 # 3395598337/2921503573 == [0;6,6,6,6,6,6,6,6,6,6,6,6] $0 = 474094764 $1 = 2921503573 end if K == 7 # 5883441196/5160664601 == [0;7,7,7,7,7,7,7,7,7,7,7,2] $0 = 722776595 $1 = 5160664601 end if K == 8 # 1383914473/1232221121 == [0;8,8,8,8,8,8,8,8,8,8] $0 = 151693352 $1 = 1232221121 end end end ifK>8 ifK<=12 if K == 9 # 4316254984/3889316089 == [0;9,9,9,9,9,9,9,9,9,9] $0 = 426938895 $1 = 3889316089 end if K == 10 # 10821200500/9846231451 == [0;10,10,10,10,10,10,10,10,10,9] $0 = 974969049 $1 = 9846231451 end if K == 11 # 11224385221/10295995854 == [0;11,11,11,11,11,11,11,11,11,4] $0 = 928389367 $1 = 10295995854 end if K == 12 # 12294320139/11354585881 == [0;12,12,12,12,12,12,12,12,12,2] $0 = 939734258 $1 = 11354585881 end end ifK>12 if K == 13 # 12879223944/11964277157 == [0;13,13,13,13,13,13,13,13,14] $0 = 914946787 $1 = 11964277157 end if K == 14 # 1637741953/1529074009 == [0;14,14,14,14,14,14,14,14] $0 = 108667944 $1 = 1529074009 end if K == 15 # 2818836061/2643386626 == [0;15,15,15,15,15,15,15,15] $0 = 175449435 $1 = 2643386626 end if K == 16 # 4688161345/4413393409 == [0;16,16,16,16,16,16,16,16] $0 = 274767936 $1 = 4413393409 end end end end ifK>16 ifK<=24 ifK<=20 if K == 17 # 7564883143/7145976130 == [0;17,17,17,17,17,17,17,17] $0 = 418907013 $1 = 7145976130 end if K == 18 # 11883239857/11259624025 == [0;18,18,18,18,18,18,18,18] $0 = 623615832 $1 = 11259624025 end if K == 19 # 18223639633/17314842634 == [0;19,19,19,19,19,19,19,19] $0 = 908796999 $1 = 17314842634 end if K == 20 # 20529271676/19554003601 == [0;20,20,20,20,20,20,20,15] $0 = 975268075 $1 = 19554003601 end end ifK>20 if K == 21 # 21127559535/20169285424 == [0;21,21,21,21,21,21,21,11] $0 = 958274111 $1 = 20169285424 end if K == 22 # 21239273075/20317644073 == [0;22,22,22,22,22,22,22,8] $0 = 921629002 $1 = 20317644073 end if K == 23 # 21713944565/20810829871 == [0;23,23,23,23,23,23,23,6] $0 = 903114694 $1 = 20810829871 end if K == 24 # 24336537390/23364692833 == [0;24,24,24,24,24,24,24,5] $0 = 971844557 $1 = 23364692833 end end end ifK>24 ifK<=28 if K == 25 # 25889378605/24895160401 == [0;25,25,25,25,25,25,25,4] $0 = 994218204 $1 = 24895160401 end if K == 26 # 25566593498/24621027601 == [0;26,26,26,26,26,26,26,3] $0 = 945565897 $1 = 24621027601 end if K == 27 # 22277961093/21483369235 == [0;27,27,27,27,27,27,27,2] $0 = 794591858 $1 = 21483369235 end if K == 28 # 28665023831/27677788993 == [0;28,28,28,28,28,28,28,2] $0 = 987234838 $1 = 27677788993 end end ifK>28 if K == 29 # 18590525547/17971551982 == [0;29,29,29,29,29,29,30] $0 = 618973565 $1 = 17971551982 end if K == 30 # 23506589012/22749125521 == [0;30,30,30,30,30,30,31] $0 = 757463491 $1 = 22749125521 end if K == 31 # 29497689565/28576814104 == [0;31,31,31,31,31,31,32] $0 = 920875461 $1 = 28576814104 end if K == 32 # 1112676449/1078990849 == [0;32,32,32,32,32,32] $0 = 33685600 $1 = 1078990849 end end end end end ifK>32 ifK<=48 ifK<=40 ifK<=36 if K == 33 # 1336683349/1297404109 == [0;33,33,33,33,33,33] $0 = 39279240 $1 = 1297404109 end if K == 34 # 1597085775/1551493033 == [0;34,34,34,34,34,34] $0 = 45592742 $1 = 1551493033 end if K == 35 # 1898469581/1845776101 == [0;35,35,35,35,35,35] $0 = 52693480 $1 = 1845776101 end if K == 36 # 2245841101/2185188193 == [0;36,36,36,36,36,36] $0 = 60652908 $1 = 2185188193 end end ifK>36 if K == 37 # 2644652109/2575105429 == [0;37,37,37,37,37,37] $0 = 69546680 $1 = 2575105429 end if K == 38 # 3100825499/3021370729 == [0;38,38,38,38,38,38] $0 = 79454770 $1 = 3021370729 end if K == 39 # 3620781685/3530320093 == [0;39,39,39,39,39,39] $0 = 90461592 $1 = 3530320093 end if K == 40 # 4211465721/4108809601 == [0;40,40,40,40,40,40] $0 = 102656120 $1 = 4108809601 end end end ifK>40 ifK<=44 if K == 41 # 4880375141/4764243133 == [0;41,41,41,41,41,41] $0 = 116132008 $1 = 4764243133 end if K == 42 # 5635588519/5504600809 == [0;42,42,42,42,42,42] $0 = 130987710 $1 = 5504600809 end if K == 43 # 6485794749/6338468149 == [0;43,43,43,43,43,43] $0 = 147326600 $1 = 6338468149 end if K == 44 # 7440323045/7275065953 == [0;44,44,44,44,44,44] $0 = 165257092 $1 = 7275065953 end end ifK>44 if K == 45 # 8509173661/8324280901 == [0;45,45,45,45,45,45] $0 = 184892760 $1 = 8324280901 end if K == 46 # 9703049331/9496696873 == [0;46,46,46,46,46,46] $0 = 206352458 $1 = 9496696873 end if K == 47 # 11033387429/10803626989 == [0;47,47,47,47,47,47] $0 = 229760440 $1 = 10803626989 end if K == 48 # 12512392849/12257146369 == [0;48,48,48,48,48,48] $0 = 255246480 $1 = 12257146369 end end end end ifK>48 ifK<=56 ifK<=52 if K == 49 # 14153071605/13870125613 == [0;49,49,49,49,49,49] $0 = 282945992 $1 = 13870125613 end if K == 50 # 15969265151/15656265001 == [0;50,50,50,50,50,50] $0 = 313000150 $1 = 15656265001 end if K == 51 # 17975685421/17630129413 == [0;51,51,51,51,51,51] $0 = 345556008 $1 = 17630129413 end if K == 52 # 20187950589/19807183969 == [0;52,52,52,52,52,52] $0 = 380766620 $1 = 19807183969 end end ifK>52 if K == 53 # 22622621549/22203830389 == [0;53,53,53,53,53,53] $0 = 418791160 $1 = 22203830389 end if K == 54 # 25297239115/24837444073 == [0;54,54,54,54,54,54] $0 = 459795042 $1 = 24837444073 end if K == 55 # 28230361941/27726411901 == [0;55,55,55,55,55,55] $0 = 503950040 $1 = 27726411901 end if K == 56 # 31441605161/30890170753 == [0;56,56,56,56,56,56] $0 = 551434408 $1 = 30890170753 end end end ifK>56 ifK<=60 if K == 57 # 34951679749/34349246749 == [0;57,57,57,57,57,57] $0 = 602433000 $1 = 34349246749 end if K == 58 # 38782432599/38125295209 == [0;58,58,58,58,58,58] $0 = 657137390 $1 = 38125295209 end if K == 59 # 42956887325/42241141333 == [0;59,59,59,59,59,59] $0 = 715745992 $1 = 42241141333 end if K == 60 # 47499285781/46720821601 == [0;60,60,60,60,60,60] $0 = 778464180 $1 = 46720821601 end end ifK>60 if K == 61 # 52435130301/51589625893 == [0;61,61,61,61,61,61] $0 = 845504408 $1 = 51589625893 end if K == 62 # 57791226659/56874140329 == [0;62,62,62,62,62,62] $0 = 917086330 $1 = 56874140329 end if K == 63 # 63595727749/62602290829 == [0;63,63,63,63,63,63] $0 = 993436920 $1 = 62602290829 end end end end end end ifK>63 # if K>63: $1=K*K # $1 := K*K+1; $1=$1+1 $0=K # $0 := K; $2=1 # $2 := 1; $3=N/K # $3 := N/K; while$1<=$3 # while $1<=(N/K): $2=$1 # $1,$0,$2 := (($1*K+$0)*K+$1),($1*K+$0),($1); $4=$1*K $0=$0+$4 $4=$0*K $1=$1+$4 end # end if$0<=$3 # if $0<=(N/K): $2=$0 # $1,$0,$2 := ($1*K+$0),($1),($0); $0=$1 $1=$0*K $1=$1+$2 end # end if$0<=N # if $0<=N: $3=N/$0 # $3 := N/$0+1; $3=$3+1 $1=$1*$3 # $1 := $1*$3+$0; $1=$1+$0 $0=$0*$3 # $0 := $0*$3+$2; $0=$0+$2 end # end end # end $2=$1-$0 # $0,$2 := ($0*N),($1-$0); $0=$0*N ifM==0 # if M==0: $2=$2+K # $0 := $0-($2+K-1)/K; $2=$2-1 $2=$2/K $0=$0-$2 end # end ifM>1 # if M>1: $3=M-1 # $3 := M-1; $4=$2/K # $0 := $0+($2/K)*(M-1); $4=$4*$3 $0=$0+$4 $2=$2%K # $0 := $0+($2%K)*(M-1)/K; $2=$2*$3 $2=$2/K $0=$0+$2 end # end $0=$0/$1 # return ($0/$1+N); $0=$0+N return$0