RosettaCodeData/Task/Modular-inverse/FutureBasic/modular-inverse.basic

11 lines
222 B
Plaintext

NSInteger local fn ModularInverse2( a as NSInteger, b as NSInteger )
a %= b
for NSInteger x = 1 to b - 1
if ( (a * x) % b == 1 ) then return x
next
end fn = -1
print fn ModularInverse2( 42, 2017 )
HandleEvents