#PHP, 47 41 bytes
PHP, 47 41 bytes
inspired by Xanderhall, but the latest idea finally justifies an own answer.
while(strstr($n+=$n=&$argn%3,51));echo$n;
or
while(strpbrk($n+=$n=&$argn%3,3));echo$n;
This takes advantage from the fact that the input is also from the sequence: For $n%3==1
, the new modulo is 2
. For $n%3==2
, the new modulo is 4-3=1
. $n%3==0
never happens.
Run as pipe with -R
or try them online.