Skip to main content
deleted 157 characters in body
Source Link
Nick Kennedy
  • 21.2k
  • 3
  • 18
  • 44

Jelly, 1313 12 bytes

r²ÆṪ=€ḢTḢƲa+¥r²ÆṪ=€Ḣ$T+⁸Ḣ 

Try it online!Try it online!

A monadic link taking an integer and returning the next integer with shared totient or zero.

Explanation

Main link (takes integer argument z)

  | Range from z to z ** 2 inclusive ÆṪ  | Totient function of each   $ Ʋ | Following as a monad =€Ḣ  | - Check whether each equal to the first, popping the first before doing so T  T | - Truthy indices    +⁸ | - Head (returns 0 if the previous link returned an emptyPlus list)z   ¥ | Following as a- dyadHead with(returns z0 asif the right argument and result of previous step aslink leftyielded (calledan xempty belowlist) a | - x and:  + | - (x + z) 

Jelly, 13 bytes

r²ÆṪ=€ḢTḢƲa+¥ 

Try it online!

A monadic link taking an integer and returning the next integer with shared totient or zero.

Explanation

Main link (takes integer argument z)

  | Range from z to z ** 2 inclusive ÆṪ  | Totient function of each   Ʋ | Following as a monad =€Ḣ  | - Check whether each equal to the first, popping the first before doing so T  | - Truthy indices    | - Head (returns 0 if the previous link returned an empty list)   ¥ | Following as a dyad with z as the right argument and result of previous step as left (called x below) a | - x and:  + | - (x + z) 

Jelly, 13 12 bytes

r²ÆṪ=€Ḣ$T+⁸Ḣ 

Try it online!

A monadic link taking an integer and returning the next integer with shared totient or zero.

Explanation

Main link (takes integer argument z)

r² | Range from z to z ** 2 inclusive ÆṪ | Totient function of each $ | Following as a monad =€Ḣ | - Check whether each equal to the first, popping the first before doing so T | Truthy indices +⁸ | Plus z  | - Head (returns 0 if the previous link yielded an empty list) 
added 614 characters in body
Source Link
Nick Kennedy
  • 21.2k
  • 3
  • 18
  • 44

Jelly, 13 bytes

r²ÆṪ=€ḢTḢƲa+¥ 

Try it online!

A monadic link taking an integer and returning the next integer with shared totient or zero.

Explanation

Main link (takes integer argument z)

r² | Range from z to z ** 2 inclusive ÆṪ | Totient function of each Ʋ | Following as a monad =€Ḣ | - Check whether each equal to the first, popping the first before doing so T | - Truthy indices Ḣ | - Head (returns 0 if the previous link returned an empty list) ¥ | Following as a dyad with z as the right argument and result of previous step as left (called x below) a | - x and: + | - (x + z) 

Jelly, 13 bytes

r²ÆṪ=€ḢTḢƲa+¥ 

Try it online!

A monadic link taking an integer and returning the next integer with shared totient or zero.

Jelly, 13 bytes

r²ÆṪ=€ḢTḢƲa+¥ 

Try it online!

A monadic link taking an integer and returning the next integer with shared totient or zero.

Explanation

Main link (takes integer argument z)

r² | Range from z to z ** 2 inclusive ÆṪ | Totient function of each Ʋ | Following as a monad =€Ḣ | - Check whether each equal to the first, popping the first before doing so T | - Truthy indices Ḣ | - Head (returns 0 if the previous link returned an empty list) ¥ | Following as a dyad with z as the right argument and result of previous step as left (called x below) a | - x and: + | - (x + z) 
Source Link
Nick Kennedy
  • 21.2k
  • 3
  • 18
  • 44

Jelly, 13 bytes

r²ÆṪ=€ḢTḢƲa+¥ 

Try it online!

A monadic link taking an integer and returning the next integer with shared totient or zero.