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

added 492 characters in body
Source Link
Zgarb
  • 43.2k
  • 4
  • 84
  • 265

Husk, 12 bytes

←1ドル¡Ṡ§|÷%oΣd

Try it online!

Explanation

←1ドル¡Ṡ§|÷%oΣd Implicit input, e.g. n=1782
 Ṡ§|÷%oΣd This part defines the transformation.
 oΣ Sum of
 d digits: s=18
 Ṡ % n mod s: 0
 §| or (take this branch if last result was 0)
 ÷ n divided by s: 99
 ¡ Iterate the transformation: [1782,99,9,1,1,1,...
 1ドル Index of 1 (1-based): 4
← Decrement: 3
 Print implicitly.

Husk, 12 bytes

←1ドル¡Ṡ§|÷%oΣd

Try it online!

Husk, 12 bytes

←1ドル¡Ṡ§|÷%oΣd

Try it online!

Explanation

←1ドル¡Ṡ§|÷%oΣd Implicit input, e.g. n=1782
 Ṡ§|÷%oΣd This part defines the transformation.
 oΣ Sum of
 d digits: s=18
 Ṡ % n mod s: 0
 §| or (take this branch if last result was 0)
 ÷ n divided by s: 99
 ¡ Iterate the transformation: [1782,99,9,1,1,1,...
 1ドル Index of 1 (1-based): 4
← Decrement: 3
 Print implicitly.
Source Link
Zgarb
  • 43.2k
  • 4
  • 84
  • 265

Husk, 12 bytes

←1ドル¡Ṡ§|÷%oΣd

Try it online!

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