Skip to main content
1 of 3
Leaky Nun
  • 50.6k
  • 6
  • 115
  • 291

#Retina, 36 bytes

.+ $*1:$&$* (?=.+:)(?!(11+)\1*:\1+$) 

Try it online!

Explanation

There are two stages (commands).

First stage

.+ $*1:$&$* 

It is a simple regex substitution, converting the input to that many ones, followed by a colon, followed by that many ones again.

For example, 5 would be converted to 11111:11111.

Second stage

(?=.+:)(?!(11+)\1*:\1+$) 

This regex tries to match the positions which satisfy the condition (co-prime with input), and then return the number of matches.

Leaky Nun
  • 50.6k
  • 6
  • 115
  • 291