Artifact ec997fea1f85e42eebd91a8a7dd07d7f858947e7:
- File nacl/demo/rowland.natcl — part of check-in [29517d12f7] at 2011-10-25 04:21:18 on branch ferrieux-nacl — Add a local copy of reference JS demo at same fps. Add an interactive tclsh page for easy timings, including toy number manipulation. (user: ferrieux, size: 406) [annotate] [blame] [check-ins using]
proc tcl::mathfunc::gcd {a b} { while {$b} {set b [expr {$a % [set a $b]}]} return $a } # Rowland's: compute a(n)-a(n-1) where a(1)=7 and # a(n) = a(n – 1) + gcd(n, a(n – 1)) proc rowland m { set a 7 set n 1 set out {} while {$n<=$m} { incr n set b $a set a [expr {$b+gcd($n,$b)}] set p [expr {$a-$b}] if {$p>1} {lappend out $p} } return $out }