Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To reel of the digits from a number, we'd only ever need to do a costly string conversion if we couldnt do a mod, digits can most quickly be pushed of a number like this:</p> <pre><code>feed=number; do { digit=feed%10; feed/=10; //use digit... eg. digitTally[digit]++; } while(feed&gt;0) </code></pre> <p>that loop should be very fast and can just be placed inside a loop of the start to end numbers for the simplest way to tally the digits.</p> <p>To go faster, for larger range of numbers, im looking for an optimised method of tallying all digits from 0 to number*10^significance (from a start to end bazzogles me)</p> <p>here is a table showing digit tallies of some single significant digits.. these are inclusive of 0, but not the top value itself, -that was an oversight but its maybe a bit easier to see patterns (having the top values digits absent here) These tallies dont include trailing zeros, </p> <pre><code> 1 10 100 1000 10000 2 20 30 40 60 90 200 600 2000 6000 0 1 1 10 190 2890 1 2 3 4 6 9 30 110 490 1690 1 0 1 20 300 4000 1 12 13 14 16 19 140 220 1600 2800 2 0 1 20 300 4000 0 2 13 14 16 19 40 220 600 2800 3 0 1 20 300 4000 0 2 3 14 16 19 40 220 600 2800 4 0 1 20 300 4000 0 2 3 4 16 19 40 220 600 2800 5 0 1 20 300 4000 0 2 3 4 16 19 40 220 600 2800 6 0 1 20 300 4000 0 2 3 4 6 19 40 120 600 1800 7 0 1 20 300 4000 0 2 3 4 6 19 40 120 600 1800 8 0 1 20 300 4000 0 2 3 4 6 19 40 120 600 1800 9 0 1 20 300 4000 0 2 3 4 6 9 40 120 600 1800 </code></pre> <blockquote> <p>edit: clearing up my origonal thoughts:</p> <p>from the brute force table showing tallies from 0 (included) to poweroTen(notinc) it is visible that a majordigit of tenpower:</p> </blockquote> <pre><code>increments tally[0 to 9] by md*tp*10^(tp-1) increments tally[1 to md-1] by 10^tp decrements tally[0] by (10^tp - 10) (to remove leading 0s if tp&gt;leadingzeros) can increment tally[moresignificantdigits] by self(md*10^tp) (to complete an effect) </code></pre> <p>if these tally adjustments were applied for each significant digit, the tally should be modified as though counted from 0 to end-1</p> <p>the adjustments can be inverted to remove preceeding range (start number)</p> <p>Thanks Aaronaught for your complete and tested answer.</p>
 

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