Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

3 of 5
added 846 characters in body
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#05AB1E, (削除) 21 (削除ここまで) (削除) 20 (削除ここまで) 19 bytes

ÎFDˆ∞.Δ ̄θy^bSO ̄yå_*

Pretty inefficient, so the larger the input, the longer it takes to get the result. Does work for input 0 as well, though.

Try it online or verify the first \$n\$ terms.

Explanation:

Î # Push 0 and the input
 F # Loop the input amount of times:
 Dˆ # Add the current number to the global_array (without popping)
 ∞.Δ # Inner loop starting at 1 to find the first number which is truthy for:
 ̄θy^ # XOR the last number of the global_array with the loop-number
 b # Convert it to binary
 SO # Sum it's binary digits
 ̄yå_ # Check if the loop-number is NOT in the global_array yet
 * # Multiply both (only if this is 1 (truthy) the inner loop will stop)
 # (after the loops, output the top of the stack implicitly)
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

AltStyle によって変換されたページ (->オリジナル) /