Message Boards Message Boards

Get the number of Integers coprime to X less than Y?

Posted 6 years ago
POSTED BY: Sam Parker
3 Replies
Posted 6 years ago

[?] Get the number of Integers coprime to X less than Y?

POSTED BY: Sam Parker
Posted 6 years ago

Thanks Marco! Exactly what I wanted

POSTED BY: Sam Parker

Hi,

this (pure) function tests whether a particular number is coprime to 35 and smaller than 20.

CoprimeQ[35, #] && # < 20 &

You can apply this to all function in a certain range:

Select[Range[-100, 100], CoprimeQ[35, #] && # < 20 &]

Of course this is not quite necessary, because technically we can add the range restriction in the first place to the input:

Select[Range[-100, 19], CoprimeQ[35, #] &]

gives the same as above.

Cheers,

Marco

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

Group Abstract Group Abstract