Finding i Given F[i] for a Given Equation

  • Context: Undergrad 
  • Thread starter Thread starter ged25
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
ged25
Messages
6
Reaction score
0
I have the following equation

F = (F[i-1] * a) % b,
F[0] = 1;

Values of a and b are given. My question is whether it is possible to mathematically determine the value of i if you are given F.
 
Mathematics news on Phys.org
Well first of all, we would have to know what that means! In some computer languages "a % b" is used to mean "the integer part of a divided by b". Is that what you mean?

It looks to me like there are going to be some values of n so that [itex]F<i>\ne n</i>[/itex] for any i so if you mean "solve F= n", then in general there is no solution. Assuming that F is, in fact, some value of F, then you could use that recursive relation to keep calculating F[1], F[2], etc. until you finally get the given F.
 
the F must obviously repeat after at most b steps, since there are at most b values F can have.

This is a Linear congruential random number generator, and you can find lots about them.
The general equation for such a generator is F = (F[i-1] * a + c) % b.

If you have c = 0, you get [tex]F<i> \equiv F[0] a^i </i>[/tex] (mod b)

If you want to calculate possible i's for an F, you'll need Eulers theorem:
If a and n are coprime then:

[tex]a^{\phi(n)} \equiv 1[/tex] (mod n)

[itex]\phi(n)[/itex] is the totient function, the number of positive integers, less than n that are coprime to n.