Group Abstract Group Abstract

Message Boards Message Boards

0
|
4K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

How do i get a random coprime from a range

Posted 11 years ago

So i want to get a random relatively prime number from a defined range. I've found the individual functions like: Range[], CoprimeQ[], Select[] and RandomChoise[]. But cant figure out how to combine them.

Lets assume the range is: r = Range[2,100]; My number to compare if relative prime is: a=100;

So desired output would be s single random number that is relatively prime to 100 say 77.

My failed attempt looks like this: RandomChoise[Select[Range[2, 100], CoprimeQ[#, 100] & /@ Range[2, 100]]]

POSTED BY: Mikael K
POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard