Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As all your numbers are rationals, the easiest (and also maybe the fastest, as it will have to do less floating point operations) would be to do the computations with rationals (tuples of 2 integers p,q), and then do just one floating point division at the end.</p> <p><strong>update</strong> to use this technique effectively you will need to use bigints for p &amp; q, as they grow quite fast...</p> <p>A fast prototype in Lisp, that has built in rationals shows:</p> <pre><code>(defun sum_harmonic (n acc) (if (= n 0) acc (sum_harmonic (- n 1) (+ acc (/ 1 n))))) (sum_harmonic 10 0) 7381/2520 [2.9289682] (sum_harmonic 100 0) 14466636279520351160221518043104131447711/278881500918849908658135235741249214272 [5.1873775] (sum_harmonic 1000 0) 53362913282294785045591045624042980409652472280384260097101349248456268889497101 75750609790198503569140908873155046809837844217211788500946430234432656602250210 02784256328520814055449412104425101426727702947747127089179639677796104532246924 26866468888281582071984897105110796873249319155529397017508931564519976085734473 01418328401172441228064907430770373668317005580029365923508858936023528585280816 0759574737836655413175508131522517/712886527466509305316638415571427292066835886 18858930404520019911543240875811114994764441519138715869117178170195752565129802 64067621009251465871004305131072686268143200196609974862745937188343705015434452 52373974529896314567498212823695623282379401106880926231770886197954079124775455 80493264757378299233527517967352480424636380511370343312147817468508784534856780 21888075373249921995672056932029099390891687487672697950931603520000 [7.485471] </code></pre> <p>So, the next better option could be to mantain the list of floating points and to reduce it summing the two smallest numbers in each step...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload