Skip to main content
Commonmark migration
Source Link

#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.

#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.

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.

`-R` saves 3+2 bytes, referencing $argn saves 1, added language tags and TiO
Source Link
Titus
  • 14.8k
  • 1
  • 24
  • 41

#PHP, 4747 41 bytes

inspired by Xanderhall, but the latest idea finally justifies an own answer imo.

<?for($n=$argv[1];strstr($n+=$n%3,51););echo$n;
while(strstr($n+=$n=&$argn%3,51));echo$n;

or

<?for($n=$argv[1];strpbrk($n+=$n%3,3););echo$n;
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.

#PHP, 47 bytes

inspired by Xanderhall, but the latest idea finally justifies an own answer imo.

<?for($n=$argv[1];strstr($n+=$n%3,51););echo$n;

or

<?for($n=$argv[1];strpbrk($n+=$n%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.

#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.

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

#PHP, 47 bytes

inspired by XanderhallXanderhall, but the latest idea finally justifies an own answer imo.

<?for($n=$argv[1];strstr($n+=$n%3,51););echo$n;

or

<?for($n=$argv[1];strpbrk($n+=$n%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.

#PHP, 47 bytes

inspired by Xanderhall, but the latest idea finally justifies an own answer imo.

<?for($n=$argv[1];strstr($n+=$n%3,51););echo$n;

or

<?for($n=$argv[1];strpbrk($n+=$n%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.

#PHP, 47 bytes

inspired by Xanderhall, but the latest idea finally justifies an own answer imo.

<?for($n=$argv[1];strstr($n+=$n%3,51););echo$n;

or

<?for($n=$argv[1];strpbrk($n+=$n%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.

Source Link
Titus
  • 14.8k
  • 1
  • 24
  • 41
Loading