Digital root/Multiplicative digital root: Difference between revisions

m
→‎{{header|Tcl}}: more informative variable names
(→‎Tcl: Added implementation)
m (→‎{{header|Tcl}}: more informative variable names)
Line 343:
}
puts ""
# The longEnough variable counts how many roots have at least 5 values accumulated for them
for {set i [set llongEnough 0]} {$llongEnough < 10} {incr i} {
set r [lindex [mdr $i] 1]
ifset root {[llengthlindex [lappend a($r)mdr $i] 1] == 5} {incr l}
if {[llength [lappend accum($root) $i]] == 5} {incr longEnough}
}
puts "MDR: \[n\u2080\u2026n\u2084\]"
puts [regsub -all . "MDR: \[n\u2080\u2026n\u2084\]" -]
for {set i 0} {$i < 10} {incr i} {
puts [format "%3d: (%s)" $i [join [lrange $aaccum($i) 0 4] ", "]]
}</lang>
{{out}}
Anonymous user