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

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) 
Nick Kennedy
  • 21.2k
  • 3
  • 18
  • 44