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 Answer

add version number for clarity
Source Link
Deadcode
  • 12.9k
  • 2
  • 71
  • 55

Retina Retina 0.8.2, 13 bytes

.+
$*
1
$`1
1

Try it online! Explanation: The first and last stages are just unary ⇔ decimal conversion. The middle stage replaces each 1 with the number of 1s to its left plus another 1 for the 1 itself, thus counting from 1 to n, summing the values implicitly.

Retina, 13 bytes

.+
$*
1
$`1
1

Try it online! Explanation: The first and last stages are just unary ⇔ decimal conversion. The middle stage replaces each 1 with the number of 1s to its left plus another 1 for the 1 itself, thus counting from 1 to n, summing the values implicitly.

Retina 0.8.2, 13 bytes

.+
$*
1
$`1
1

Try it online! Explanation: The first and last stages are just unary ⇔ decimal conversion. The middle stage replaces each 1 with the number of 1s to its left plus another 1 for the 1 itself, thus counting from 1 to n, summing the values implicitly.

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina, 13 bytes

.+
$*
1
$`1
1

Try it online! Explanation: The first and last stages are just unary ⇔ decimal conversion. The middle stage replaces each 1 with the number of 1s to its left plus another 1 for the 1 itself, thus counting from 1 to n, summing the values implicitly.

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