View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
jasonsweeney[_87_] jasonsweeney[_87_] is offline
external usenet poster
 
Posts: 1
Default Storing Data in code? (relative primes to MOD as example)


I have been tinkering with collection, but have not had much luck making
it work. A simple example of a collection code populated by looping
procedure would be greatly appreciated.

By the way, the code I used for finding a single multiplicative inverse
of a modulus follows below.

___________________________
Sub Multiplicative_Inverse()
'
Range("A1:B10000").Value = ""
'
'Inverse_Function = (P*N)-D*INT((P*N)/D)
'd = range("e1").value
'n = range("e2").value
'
'Basic Mod Formula: MOD(n, d) = n - d*INT(n/d)
'Where n = number, d = modulus
'5P MOD 26
'
Dim n As Double
Dim d As Double
Dim p As Double
Dim Inverse_function As Double
'
count_num = 3
n = Range("e2").Value
p = 0
d = Range("e1").Value
Do Until Inverse_function = 1 Or p = d

Inverse_function = (p * n) - d * Int((p * n) / d)
p = p + 1
count_num = count_num + 1
Sheet1.Cells(count_num, 1).Value = p - 1
Sheet1.Cells(count_num, 2).Value = Inverse_function
Loop
If Inverse_function = 1 Then
Range("A1").Value = p - 1
Else
Range("A1").Value = "Not 1 to 1."
End If
End Sub



-- Jason


--
jasonsweeney
------------------------------------------------------------------------
jasonsweeney's Profile: http://www.excelforum.com/member.php...fo&userid=5222
View this thread: http://www.excelforum.com/showthread...hreadid=397484