Chinese remainder theorem: Difference between revisions
Content deleted Content added
add picolisp |
|||
Line 929:
@(100) = 2 : @(101) = 3 : @(102) = 2
Print Func (_Chinese_Remainder (3))
' -------------------------------------
Line 937 ⟶ 936:
@(100) = 10 : @(101) = 04 : @(102) = 12
Print Func (_Chinese_Remainder (3))
' -------------------------------------
Line 945 ⟶ 943:
' returns x where (a * x) % b == 1
_Mul_Inv Param
Local (
c@ = b@
Line 955 ⟶ 950:
e@ = 1
If b@ = 1 Then Return (1)
Do While a@ > 1
Line 968 ⟶ 960:
If e@ < 0 Then e@ = e@ + c@
Return (e@)▼
▲Return
_Chinese_Remainder Param
Local (5)
b@ = 1
c@ = 0
Line 985 ⟶ 975:
For d@ = 0 Step 1 While d@ < a@
e@ = b@ / @(d@)
Next
</lang>
{{out}}
Line 997 ⟶ 985:
1000
0 OK, 0:
</pre>
|