Digital root: Difference between revisions

add BQN
(add BQN)
Line 1,014:
Digital root: 1
Additive Persistence: 3</pre>
 
=={{header|BQN}}==
A recursive implementation which takes the root and persistence in base 10.
 
Other bases can be used by changing the <code>DSum</code> function, which is derived from a [https://mlochbaum.github.io/bqncrate/ BQNcrate] idiom.
 
<lang bqn>DSum ← +´10{⌽𝕗|⌊∘÷⟜𝕗⍟(↕1+·⌊𝕗⋆⁼1⌈⊢)}
Root ← 0⊸{(×○⌊÷⟜10)◶⟨𝕨‿𝕩,(1+𝕨)⊸𝕊 Dsum⟩𝕩}
 
P ← •Show ⊢∾Root
P 627615
P 39390
P 588225
P 393900588225</lang>
<lang>⟨ 627615 0 627615 ⟩
⟨ 39390 0 39390 ⟩
⟨ 588225 0 588225 ⟩
⟨ 393900588225 0 393900588225 ⟩</lang>
[https://mlochbaum.github.io/BQN/try.html#code=RFN1bSDihpAgK8K0MTB74oy98J2Vl3zijIriiJjDt+KfnPCdlZfijZ8o4oaVMSvCt+KMivCdlZfii4bigbwx4oyI4oqiKX0KUm9vdCDihpAgMOKKuHsow5fil4vijIrDt+KfnDEwKeKXtuKfqPCdlajigL/wnZWpLCgxK/Cdlagp4oq48J2ViiBEc3Vt4p+p8J2VqX0KClAg4oaQIOKAolNob3cg4oqi4oi+Um9vdApQIDYyNzYxNQpQIDM5MzkwClAgNTg4MjI1ClAgMzkzOTAwNTg4MjI1Cg== Try It!]
 
=={{header|Bracmat}}==
236

edits