r354 vs r355
......
15611561
몫으로 기록할 숫자의 첫번째 자리를 구했다면, 그 다음 자리의 숫자를 찾기 위해 (변수 tn으로 만들 수 있는 여분의 1자리 +) 18자리 + 18자리 숫자를 18자리+18자리 숫자로 나누는 계산을 합니다. tn이 9가 될 경우 9로 시작하는 19자리 숫자를 long integer로 모두 표현할 수 없으므로 10**18 자리부터 먼저 계산합니다. 10**18의 1번째 숫자의 몫을 구한 다음 나머지를 18자리 숫자에 더하는 과정(part 1)을 거친 다음 그 18자리에서 몫을 구하는 과정(part 2)을 거칩니다.
15621562
15631563
au와 ab를 정수로 다시 바꾸고 tz를 0으로 초기화합니다. 그리고 tn이 빈 문자열이 아니라면 (앞에 au에서 한 자리 수를 떼온 것이므로) tn에 0을 더하여 19자리로 만들고 몫을 구합니다.
1564
{{{#!if au=+au, ab=+ab, tz=0, tn!=""
1564
{{{#!if au=+au, ab=+ab, tz=0, !br&&(tn!="")
15651565
tn을 19자리 정수로 바꿉니다.
15661566
{{{#!if tn+=pd, tn=+tn
15671567
}}}
......
16211621
}}}}}}
16221622
##i=2
16231623
이후부터 과정은 동일합니다. 많아야 소수점 위 36자리, 소수점 아래 36자리 모두를 쓰면 72개이므로 총 72회(for i=0 to i=71)를 진행합니다.
1624
{{{#!if au=+au, ab=+ab, tz=0, !br&&(tn!="")
1625
{{{#!if tn+=pd, tn=+tn, tz=tn/bu, tx=bu*tz, ty=bb*tz
1626
}}}{{{#!if ty=ty.toString(), ty.length==19
1627
{{{#!if tx+=+(ty.substr(0,1)), ty=ty.substr(1,18)
1624
{{{#!if au=+au, ab=+ab, !br&&(tn!="")
1625
{{{#!if tn+=pd, tn=+tn, tz=tn/bu, tx=bu*tz, ty=bb*tz, ty=ty.toString(), ps=(ty.length==19), tx=ps?tx+(+ty.substr(0,1)):tx, ty=ps?ty=ty.substr(1):ty, ty=+ty
1626
}}}{{{#!if (tx>tn)||((tx==tn)&&(ty>0))
1627
{{{#!if tz=(tz==0):0:tz-1, tx=bu*tz, ty=bb*tz, ty=ty.toString(), ps=(ty.length==19), tx=ps?tx+(+ty.substr(0,1)):tx, ty=ps?ty=ty.substr(1):ty, ty=+ty
16281628
}}}}}}
1629
{{{#!if ty=+ty, (tx>tn)||((tx==tn)&&(ty>0))
1630
{{{#!if tz-=1, tx=bu*tz, ty=bb*tz
1631
}}}{{{#!if ty=ty.toString(), ty.length==19
1632
{{{#!if tx+=+(ty.substr(0,1)), ty=ty.substr(1,18)
1633
}}}}}}{{{#!if ty=+ty
1634
}}}}}}
16351629
{{{#!if ty>ab
16361630
{{{#!if tn-=1, ab+=+("1"+pd)
16371631
}}}}}}{{{#!if au+=(tn-tx), ab-=ty, tn=""
1632
}}}}}}{{{#!if !br
1633
{{{#!if tw=au/bu, tx=bu*tw, ty=bb*tw, ty=ty.toString(), ps=(ty.length==19), tx=ps?tx+(+ty.substr(0,1)):tx, ty=ps?ty=ty.substr(1):ty, ty=+ty, (tx>au)||((tx==au)&&(ty>ab))
1634
{{{#!if tw-=1, tx=bu*tw, ty=bb*tw, ty=ty.toString(), ps=(ty.length==19), tx=ps?tx+(+ty.substr(0,1)):tx, ty=ps?ty=ty.substr(1):ty, ty=+ty,
16381635
}}}}}}
1639
{{{#!if !br
1640
{{{#!if ps=false, (au<bu)||((au==bu)&&(ab<bb))
1641
{{{#!if ps=true, tw=0
1642
}}}}}}
1643
{{{#!if !ps
1644
{{{#!if tw=au/bu, tx=bu*tw, ty=bb*tw
1645
}}}{{{#!if ty=ty.toString(), ty.length==19
1646
{{{#!if tx+=+(ty.substr(0,1)), ty=ty.substr(1,18)
1647
}}}}}}
1648
{{{#!if ty=+ty, (tx>au)||((tx==au)&&(ty>ab))
1649
{{{#!if tw-=1, tx=bu*tw, ty=bb*tw
1650
}}}{{{#!if ty=ty.toString(), ty.length==19
1651
{{{#!if tx+=+(ty.substr(0,1)), ty=ty.substr(1,18)
1652
}}}}}}{{{#!if ty=+ty
1653
}}}}}}
16541636
{{{#!if ty>ab
16551637
{{{#!if au-=1, ab+=+("1"+pd)
1656
}}}}}}{{{#!if au-=tx, ab-=ty
1657
}}}}}}
1658
{{{#!if tw+=tz, tw=tw.toString(), tm+=tw
1638
}}}}}}{{{#!if au-=tx, ab-=ty, tw+=tz, tw=tw.toString(), tm+=tw
16591639
}}}
16601640
{{{#!if (au==0)&&(ab==0)
16611641
{{{#!if br=true
16621642
}}}}}}}}}
16631643
{{{#!if !br
1664
{{{#!if au=au.toString(), ab=ab.toString()
1665
}}}{{{#!if tn="", ps=(au.length==18), ps
1666
{{{#!if tn=au.substr(0,1), au=au.substr(1,17)
1667
}}}}}}{{{#!if !ps&&(au.length<17)
1668
{{{#!if au=pd+au, au=au.substr(au.length-17,17)
1669
}}}}}}{{{#!if ab.length<18
1670
{{{#!if ab=pd+ab, ab=ab.substr(ab.length-18,18)
1671
}}}}}}{{{#!if au+=ab.substr(0,1), ab=ab.substr(1,17)+"0"
1644
{{{#!if au=au.toString(), ab=ab.toString(), ps=(au.length==18), tn=ps?au.substr(0,1):"", au=ps?au.substr(1):(pd+au).substr(-17), ab=(ab.length<18)?(pd+ab).substr(-18):ab, au+=ab.substr(0,1), ab=ab.substr(1)+"0"
16721645
}}}}}}
16731646
##i=3
16741647
{{{#!if au=+au, ab=+ab, tz=0, !br&&(tn!="")
......