Posted to tcl by kbk at Sat Jun 15 16:27:17 GMT 2019view raw

  1. proc facs {N} {
  2. set lnfac 0.
  3. for {set n 2} {$n <= $N} {incr n} {
  4. puts "n = $n"
  5.  
  6. # accumulate log(n!)
  7.  
  8. set lnfac [expr {$lnfac + log($n)}]
  9. puts [format {ln(n!) = %e n! = %g} $lnfac [expr {exp($lnfac)}]]
  10.  
  11. # calculate log(b), and b itself
  12.  
  13. set lnb [expr {$lnfac / $n}]
  14. set b [expr {entier(ceil(exp($lnb)))}]
  15. puts [format {ln(b) = %e b = %g} $lnb $b]
  16.  
  17. # format n! in floating point - with excess precision, but who cares
  18.  
  19. set lognfac [expr {$lnfac/log(10.)}]
  20. set charnfac [expr {int($lognfac)}]
  21. set signfac [expr {10.**($lognfac - $charnfac)}]
  22. puts "$n! = ${signfac}E${charnfac}"
  23.  
  24. # format b**n in floating point, again with excess precision
  25.  
  26. set logbton [expr {$n * log($b) / log(10.)}]
  27. set charbton [expr {int($logbton)}]
  28. set sigbton [expr {10.**($logbton - $charbton)}]
  29. puts "$b**$n = ${sigbton}E${charbton}"
  30.  
  31. }
  32. return
  33. }
  34.  
  35. facs 10000
  36.  

Comments

Posted by CecilWesterhof at Sun Jun 16 11:21:55 GMT 2019 [text] [code]

I implemented the old fashioned way what I mend: http://paste.tclers.tk/5173. Later I hope to implement your idea. By the way it was already at oeis: http://oeis.org/A065027. They have the list up-to 10.000. I am a 'little' further, so I will offer them my data.