#PHP, (削除) 61 (削除ここまで)(削除) 52 (削除ここまで) 48 bytes
PHP, (削除) 61 (削除ここまで)(削除) 52 (削除ここまで) 48 bytes
saved 9 bytes thanks to @user59178, 4 bytes by merging the loops.
Recursion in PHP is bulky due to the function key word; so I use iteration.
And with a "small"few tricks, I now even beat Arnauld ́s JS.
while(++$k%++$i?$i>$argv[1]?0:$i=1:$k--);echo$k;
takes input from command line argument. Run with -r.
breakdown
while(++$k%++$i? # loop $i up; if it does not divide $k
$i>$argv[1]?0 # break if $i (smallest non-divisor of $k) is larger than input
:$i=1 # while not, reset $i and continue loop with incremented $k
:$k--); # undo increment while $i divides $k
echo$k; # print $k
ungolfed
That ́s actually two loops in one:
while($i<=$argv[1]) # loop while $i (smallest non-divisor of $k) is not larger than input
for($k++, # loop $k up from 1
$i=0;$k%++$i<1;); # loop $i up from 1 while it divides $k
echo$k; # print $k
Note: copied from my answer on the duplicate
#PHP, (削除) 61 (削除ここまで)(削除) 52 (削除ここまで) 48 bytes
saved 9 bytes thanks to @user59178, 4 bytes by merging the loops.
Recursion in PHP is bulky due to the function key word; so I use iteration.
And with a "small"few tricks, I now even beat Arnauld ́s JS.
while(++$k%++$i?$i>$argv[1]?0:$i=1:$k--);echo$k;
takes input from command line argument. Run with -r.
breakdown
while(++$k%++$i? # loop $i up; if it does not divide $k
$i>$argv[1]?0 # break if $i (smallest non-divisor of $k) is larger than input
:$i=1 # while not, reset $i and continue loop with incremented $k
:$k--); # undo increment while $i divides $k
echo$k; # print $k
ungolfed
That ́s actually two loops in one:
while($i<=$argv[1]) # loop while $i (smallest non-divisor of $k) is not larger than input
for($k++, # loop $k up from 1
$i=0;$k%++$i<1;); # loop $i up from 1 while it divides $k
echo$k; # print $k
Note: copied from my answer on the duplicate
PHP, (削除) 61 (削除ここまで)(削除) 52 (削除ここまで) 48 bytes
saved 9 bytes thanks to @user59178, 4 bytes by merging the loops.
Recursion in PHP is bulky due to the function key word; so I use iteration.
And with a "small"few tricks, I now even beat Arnauld ́s JS.
while(++$k%++$i?$i>$argv[1]?0:$i=1:$k--);echo$k;
takes input from command line argument. Run with -r.
breakdown
while(++$k%++$i? # loop $i up; if it does not divide $k
$i>$argv[1]?0 # break if $i (smallest non-divisor of $k) is larger than input
:$i=1 # while not, reset $i and continue loop with incremented $k
:$k--); # undo increment while $i divides $k
echo$k; # print $k
ungolfed
That ́s actually two loops in one:
while($i<=$argv[1]) # loop while $i (smallest non-divisor of $k) is not larger than input
for($k++, # loop $k up from 1
$i=0;$k%++$i<1;); # loop $i up from 1 while it divides $k
echo$k; # print $k
Note: copied from my answer on the duplicate
#PHP, (削除) 61 (削除ここまで) (削除) 52 (削除ここまで) 48 bytes
saved 9 bytes thanks to @user59178, 4 bytes by merging the loops.
Recursion in PHP is bulky due to the function key word; so I use iteration.
And with a "small"few tricks, I now even beat Arnauld ́s JS Arnauld ́s JS.
while(++$k%++$i?$i>$argv[1]?0:$i=1:$k--);echo$k;
takes input from command line argument. Run with -r.
breakdown
while(++$k%++$i? # loop $i up; if it does not divide $k
$i>$argv[1]?0 # break if $i (smallest non-divisor of $k) is larger than input
:$i=1 # while not, reset $i and continue loop with incremented $k
:$k--); # undo increment while $i divides $k
echo$k; # print $k
ungolfed
That ́s actually two loops in one:
while($i<=$argv[1]) # loop while $i (smallest non-divisor of $k) is not larger than input
for($k++, # loop $k up from 1
$i=0;$k%++$i<1;); # loop $i up from 1 while it divides $k
echo$k; # print $k
Note: copied from my answer on the duplicate my answer on the duplicate
#PHP, (削除) 61 (削除ここまで) (削除) 52 (削除ここまで) 48 bytes
saved 9 bytes thanks to @user59178, 4 bytes by merging the loops.
Recursion in PHP is bulky due to the function key word; so I use iteration.
And with a "small"few tricks, I now even beat Arnauld ́s JS.
while(++$k%++$i?$i>$argv[1]?0:$i=1:$k--);echo$k;
takes input from command line argument. Run with -r.
breakdown
while(++$k%++$i? # loop $i up; if it does not divide $k
$i>$argv[1]?0 # break if $i (smallest non-divisor of $k) is larger than input
:$i=1 # while not, reset $i and continue loop with incremented $k
:$k--); # undo increment while $i divides $k
echo$k; # print $k
ungolfed
That ́s actually two loops in one:
while($i<=$argv[1]) # loop while $i (smallest non-divisor of $k) is not larger than input
for($k++, # loop $k up from 1
$i=0;$k%++$i<1;); # loop $i up from 1 while it divides $k
echo$k; # print $k
Note: copied from my answer on the duplicate
#PHP, (削除) 61 (削除ここまで) (削除) 52 (削除ここまで) 48 bytes
saved 9 bytes thanks to @user59178, 4 bytes by merging the loops.
Recursion in PHP is bulky due to the function key word; so I use iteration.
And with a "small"few tricks, I now even beat Arnauld ́s JS.
while(++$k%++$i?$i>$argv[1]?0:$i=1:$k--);echo$k;
takes input from command line argument. Run with -r.
breakdown
while(++$k%++$i? # loop $i up; if it does not divide $k
$i>$argv[1]?0 # break if $i (smallest non-divisor of $k) is larger than input
:$i=1 # while not, reset $i and continue loop with incremented $k
:$k--); # undo increment while $i divides $k
echo$k; # print $k
ungolfed
That ́s actually two loops in one:
while($i<=$argv[1]) # loop while $i (smallest non-divisor of $k) is not larger than input
for($k++, # loop $k up from 1
$i=0;$k%++$i<1;); # loop $i up from 1 while it divides $k
echo$k; # print $k
Note: copied from my answer on the duplicate
#PHP, (削除) 61 (削除ここまで) (削除) 52 (削除ここまで) 48 bytes
saved 9 bytes thanks to @user59178, 4 bytes by merging the loops.
Recursion in PHP is bulky due to the function key word; so I use iteration.
And with a "small"few tricks, I now even beat Arnauld ́s JS.
while(++$k%++$i?$i>$argv[1]?0:$i=1:$k--);echo$k;
takes input from command line argument. Run with -r.
breakdown
while(++$k%++$i? # loop $i up; if it does not divide $k
$i>$argv[1]?0 # break if $i (smallest non-divisor of $k) is larger than input
:$i=1 # while not, reset $i and continue loop with incremented $k
:$k--); # undo increment while $i divides $k
echo$k; # print $k
ungolfed
That ́s actually two loops in one:
while($i<=$argv[1]) # loop while $i (smallest non-divisor of $k) is not larger than input
for($k++, # loop $k up from 1
$i=0;$k%++$i<1;); # loop $i up from 1 while it divides $k
echo$k; # print $k
Note: copied from my answer on the duplicate