Integer Ratios and Integer Density - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Integer Ratios and Integer Density (/thread-19697.html) |
Integer Ratios and Integer Density - Eddie W. Shore - 03-22-2023 03:14 AM How Many Integers Fit the Criteria? The program INTDENS calculates the ratio of integers to a range of integer that fit a criteria. The seven ratios that the program offers are: 1. The number of odd integers over the range of integers 2. The number of even integers over the range of integers 3. The number of integers equally divisible by N over the range of integers. The user sets the value of N. 4. The number of perfect squares over the range of integers. An integer is a perfect square when the fractional part of integer is zero. Examples are perfect squares are 1, 4, 9, 16, and 25. 5. The number of integers that begin with digit N over the range of integers. N is the digit 0-9. 6. The number of integers that are triangular numbers over the range of integers. a triangular number is an integer of the form (n * (n + 1)) / 2. 7. The number of integers that are relativity prime to N over the range of integers. An integer is relatively prime to N when the greatest common divisor between N and that integer is 1. The program can be used for testing whether density exists with the criteria. The density, if it exists, is defined as: limit n → ∞ (number of integers from 0 to n-1 that fit a criteria) / (n - 1) For example: the integer density of odd integers is 1/2, while the integer density of integers divisible by 6 is 1/6. Beware if the limit tends towards 0 as n gets large, such as the number of perfect squares or triangular numbers. HP Prime Program: INTDENS Code: Code: EXPORT INTDENS() Examples For this set of examples: A = 1 (low), B = 3000 (high) Ratio of odd integers: 1/2 Ratio of even integers: 1/2 Ratio of integers divisible by 5 (N = 5): 1/5 Ratio of perfect squares: 9/500 Ratio of integers beginning with 2: 1111/3000 Ratio of triangular numbers: 19/750 Ratio of integers relatively prime to 250 (N = 250): 2/5 Source Diaconis, Persi and Brian Skyrms Ten Great Ideas About Chance Princeton University Press: Princeton, NJ. 2018. ISBN 978-0-691-19639-8 |