Fun with Primes (Sum, Reciprocal Sum, Reciprocal Product) - 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: Fun with Primes (Sum, Reciprocal Sum, Reciprocal Product) (/thread-7090.html) |
Fun with Primes (Sum, Reciprocal Sum, Reciprocal Product) - Eddie W. Shore - 10-23-2016 04:14 AM Sum of the Fist n Primes Let p be a prime number. That is, p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, …} The sum of the first prime numbers is: Σ p_k from k = 1 to n HP Prime Program SPRIMES: Sum of the First n Primes Code: EXPORT SPRIMES(n) Sum of the First n Prime Reciprocals Σ 1/(p_k) from k = 1 to n HP Prime Program ISPRIMES: Sum of first n Prime Reciprocals Code: EXPORT ISPRIMES(n) It does not appear that there series of sums do not converge as n approaches ∞ (infinity). ISPRIMES(25) returns 1.80281720104 ISPRIMES(50) returns 1.96702981491 ISPRIMES(100) returns 2.10634212145 ISPRIMES(10000) returns 2.70925824876 Product of the First n Prime Reciprocals Π 1/(p_k) from k = 1 to n HP PRIME Program IPPRIMES Code: EXPORT IPPRIMES(n) Unlike ISPRIMES, IPPRIMES approaches 0 as n approaches ∞. IPPRIMES(25) returns 4.33732605429E-37 IPPRIMES(50) returns 5.24156625851E-92 IPPRIMES(100) returns 2.12227225409E-220 IPPRIMES(10000) returns 0 |