MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Finding a relative prime

  • To: mathgroup at
  • Subject: [mg19694] RE: [mg19682] Finding a relative prime
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Sat, 11 Sep 1999 16:36:02 -0400
  • Sender: owner-wri-mathgroup at

Timur Tabi  wrote:
I'm using Mathematica 3.0 for the Mac, and I'm trying to figure out how to
get it to pick a random number that is relatively prime to another number,
p-1, where p is prime.  In other words, pick a random number k such that 
1) k is between 2 and p-1, 
2) k is relatively prime to p-1.


This should work:


However, when p=2,3,5,7
there is only one integer less than (p-1)
that is relatively prime to (p-1), and that doesn't 
allow for a very random outcome.

Ted Ersek

For Mathematica tips, tricks see

  • Prev by Date: Re: Version 3 vs Version 4
  • Next by Date: direction field plots
  • Previous by thread: Finding a relative prime
  • Next by thread: Re: Finding a relative prime