pi - The ratio of a circles circumference to its diameter.Compiled by Paul Bourke100 Decimal places 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 Base 2 11.0010010000111111011010101000100010000101101000110000100011010011 Approximations 22/7 is correct to 3 decimal places (used by Egyptians around 1000BC) In the 3rd century Archimedes approximated a circle by a 96 sided polygon and determined that 3 + 10/71 < pi < 3 + 1/7. 666/212 is correct to 4 decimal places. 355/113 is correct to 6 decimal places. 104348/33215 is correct to 8 decimal places. Nearly one of the roots to 9x4 - 240x2 + 1492 = 0
Series Expansions The following is attributed to the English mathematician John Wallis in 1655.
4 * 4 * 6 * 6 * 8 * 8 * 10 * 10 * 12 * 12 ..... pi = 8 * ------------------------------------------------- 3 * 3 * 5 * 5 * 7 * 7 * 9 * 9 * 11 * 11 .... This one by the Scottish mathematician and astronomer James Gregory in 1671 pi = 4 * (1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ....) And this one by the Swiss mathematician Leonard Euler. pi = sqrt(12 - (12/22) + (12/32) - (12/42) + (12/52) .... ) Some more involved expansions are given below. pi = pi = pi = If a needle of unit length is randomly thrown onto a plane which is covered with parallel lines 1 unit apart the probability that the needle will intersect a line is 2/pi. The probability that two integers chosen at random have no common factors greater than 1 is 6/pi2 More decimal places
3.1415926535897932384626433832795028841971693993751058209749445923078164062 862089986280348253421170679821480865132823066470938446095505822317253594081284 811174502841027019385211055596446229489549303819644288109756659334461284756482 337867831652712019091456485669234603486104543266482133936072602491412737245870 066063155881748815209209628292540917153643678925903600113305305488204665213841 469519415116094330572703657595919530921861173819326117931051185480744623799627 495673518857527248912279381830119491298336733624406566430860213949463952247371 907021798609437027705392171762931767523846748184676694051320005681271452635608 277857713427577896091736371787214684409012249534301465495853710507922796892589 235420199561121290219608640344181598136297747713099605187072113499999983729780 499510597317328160963185950244594553469083026425223082533446850352619311881710 100031378387528865875332083814206171776691473035982534904287554687311595628638 823537875937519577818577805321712268066130019278766111959092164201989380952572 010654858632788659361533818279682303019520353018529689957736225994138912497217 752834791315155748572424541506959508295331168617278558890750983817546374649393 192550604009277016711390098488240128583616035637076601047101819429555961989467 678374494482553797747268471040475346462080466842590694912933136770289891521047 521620569660240580381501935112533824300355876402474964732639141992726042699227 967823547816360093417216412199245863150302861829745557067498385054945885869269 956909272107975093029553211653449872027559602364806654991198818347977535663698 074265425278625518184175746728909777727938000816470600161452491921732172147723 501414419735685481613611573525521334757418494684385233239073941433345477624168 625189835694855620992192221842725502542568876717904946016534668049886272327917 860857843838279679766814541009538837863609506800642251252051173929848960841284 886269456042419652850222106611863067442786220391949450471237137869609563643719 172874677646575739624138908658326459958133904780275900994657640789512694683983 525957098258226205224894077267194782684826014769909026401363944374553050682034 962524517493996514314298091906592509372216964615157098583874105978859597729754 989301617539284681382686838689427741559918559252459539594310499725246808459872 736446958486538367362226260991246080512438843904512441365497627807977156914359 977001296160894416948685558484063534220722258284886481584560285060168427394522 674676788952521385225499546667278239864565961163548862305774564980355936345681 743241125150760694794510965960940252288797108931456691368672287489405601015033 086179286809208747609178249385890097149096759852613655497818931297848216829989 487226588048575640142704775551323796414515237462343645428584447952658678210511 413547357395231134271661021359695362314429524849371871101457654035902799344037 420073105785390621983874478084784896833214457138687519435064302184531910484810 053706146806749192781911979399520614196634287544406437451237181921799983910159 195618146751426912397489409071864942319615679452080951465502252316038819301420 937621378559566389377870830390697920773467221825625996615014215030680384477345 492026054146659252014974428507325186660021324340881907104863317346496514539057 962685610055081066587969981635747363840525714591028970641401109712062804390397 595156771577004203378699360072305587631763594218731251471205329281918261861258 673215791984148488291644706095752706957220917567116722910981690915280173506712 748583222871835209353965725121083579151369882091444210067510334671103141267111 369908658516398315019701651511685171437657618351556508849099898599823873455283 316355076479185358932261854896321329330898570642046752590709154814165498594616 371802709819943099244889575712828905923233260972997120844335732654893823911932 597463667305836041428138830320382490375898524374417029132765618093773444030707 469211201913020330380197621101100449293215160842444859637669838952286847831235 526582131449576857262433441893039686426243410773226978028073189154411010446823 252716201052652272111660396
PHI, the golden ratio(Also known as the golden mean)
Written by Paul Bourke Definition
Break a line segment into two such that the ratio of the whole to the longest segment is the same as the ratio of the two segments. From the diagram below. The condition can expressed as a/b = 1/a. This can be rearranged and expressed as a quadratic. There are two solutions, phi-1 and -phi where This is the original Greek definition, often phi-1 is used instead.
Normally the quadratic for which phi is the quoted solution is
Relationships
Continued fractions phi = phi = sqrt(1 + sqrt(1 + sqrt(1 + sqrt(1 + .....)))) Relationship to the Fibonacci series
Consider the first order Fibonacci series
This tends to phi as i tends to infinity. That is, the ratio of consecutive terms in such a series approaches phi, this is true independent of the starting points of the series. The zero order series starts with 1 and 1 as below. 1 1 2 3 5 8 13 21 34 55 89 etcthe ratio of consecutive pairs are 1 0.5 0.67 0.6 0.625 0.6154 0.619 0.6176 0.6182 etc The ratio of terms of this series as converged to 3 decimal places after only 10 terms. 2 dimensional golden ratio
An alternative definition which is the 2D version of the original definition based on the line segment is: "find a rectangle such that when a square is removed the remaining rectangle has the same proportions as the original". The solution to this is a rectangle with the ratio of its sides being phi. These rectangles can be inscribed in a so called logarithmic spiral also known as equiangular spirals. Such spirals and occur frequently in nature, for example: shells, sunflowers, and pine cones. The limit point of the spiral is called the "eye of God". Phi Pyramid
Find an additive series such that
The only solution is the series
Note: the terms of the series describe a 1,phi Fibonacci sequence. Phi to 1000 decimal places1.618033988749894848204586834365638117720309179805762862135448 622705260462818902449707207204189391137484754088075386891752 126633862223536931793180060766726354433389086595939582905638 322661319928290267880675208766892501711696207032221043216269 548626296313614438149758701220340805887954454749246185695364 864449241044320771344947049565846788509874339442212544877066 478091588460749988712400765217057517978834166256249407589069 704000281210427621771117778053153171410117046665991466979873 176135600670874807101317952368942752194843530567830022878569 978297783478458782289110976250030269615617002504643382437764 861028383126833037242926752631165339247316711121158818638513 316203840052221657912866752946549068113171599343235973494985 090409476213222981017261070596116456299098162905552085247903 524060201727997471753427775927786256194320827505131218156285 512224809394712341451702237358057727861600868838295230459264 787801788992199027077690389532196819861514378031499741106926 088674296226757560523172777520353613936
sqrt(2) - square root of two1000 decimal places
1.41421356237309504880168872420969807856967187537694807317667 9737990732478462107038850387534327641572735013846230912297024 9248360558507372126441214970999358314132226659275055927557999 5050115278206057147010955997160597027453459686201472851741864 0889198609552329230484308714321450839762603627995251407989687 2533965463318088296406206152583523950547457502877599617298355 7522033753185701135437460340849884716038689997069900481503054 4027790316454247823068492936918621580578463111596668713013015 6185689872372352885092648612494977154218334204285686060146824 7207714358548741556570696776537202264854470158588016207584749 2265722600208558446652145839889394437092659180031138824646815 7082630100594858704003186480342194897278290641045072636881313 7398552561173220402450912277002269411275736272804957381089675 0401836986836845072579936472906076299694138047565482372899718 0326802474420629269124859052181004459842150591120249441341728 5314781058036033710773091828693147101711116839165817268894197 5871658215212822951848847
e - base of the natural logarithmCompiled by Paul BourkeDefinitions
If you are paid 100% interest on an investment which is compounded continuously then you will multiply your investment by e each year. Mathematically
Also
Another nice characteristic of e, what function equals it's own derivative, the answer is f(x) = ex 1000 decimal places
2.71828182845904523536028747135266249775724709369995957496696 7627724076630353547594571382178525166427427466391932003059921 8174135966290435729003342952605956307381323286279434907632338 2988075319525101901157383418793070215408914993488416750924476 1460668082264800168477411853742345442437107539077744992069551 7027618386062613313845830007520449338265602976067371132007093 2870912744374704723069697720931014169283681902551510865746377 2111252389784425056953696770785449969967946864454905987931636 8892300987931277361782154249992295763514822082698951936680331 8252886939849646510582093923982948879332036250944311730123819 7068416140397019837679320683282376464804295311802328782509819 4558153017567173613320698112509961818815930416903515988885193 4580727386673858942287922849989208680582574927961048419844436 3463244968487560233624827041978623209002160990235304369941849 1463140934317381436405462531520961836908887070167683964243781 4059271456354906130310720851038375051011574770417189861068739 6965521267154688957035035 The following relationship links i = sqrt(-1), pi, and e together
ln(10) - natural logarithm of ten1000 decimal places
2.30258509299404568401799145468436420760110148862877297603332 7900967572609677352480235997205089598298341967784042286248633 4095254650828067566662873690987816894829072083255546808437998 9482623319852839350530896537773262884616336622228769821988674 6543667474404243274365155048934314939391479619404400222105101 7141748003688084012647080685567743216228355220114804663715659 1213734507478569476834636167921018064450706480002775026849167 4655058685693567342067058113642922455440575892572420824131469 5689016758940256776311356919292033376587141660230105703089634 5720754403708474699401682692828084811842893148485249486448719 2780967627127577539702766860595249671667418348570442250719796 5004714951050492214776567636938662976979522110718264549734772 6624257094293225827985025855097852653832076067263171643095059 9508780752371033310119785754733154142180842754386359177811705 4309827482385045648019095610299291824318237525357709750539565 1876975103749708886921802051893395072385392051446341972652872 8696511086257149219884997
Sumerian ArithmeticWritten by Paul BourkeMarch 1999
The ancient Sumerian mathematics was based upon a weird mixture of base 6 and 10. In our decimal system a number is decomposed into multiples of powers of ten. In the general case one finds solutions for the ai coefficients so that following sum equals the number in question. So for example 8562 = 8 * 103 + 5 * 102 + 6 * 101 + 2 * 100
Arithmetic in other bases follows the same system, for example, in base 6 a number is represented as follows. For example, the base 10 number 8562 would be written as 103350
The Sumerian system was built up of an alternating mixture of the two bases, 10 and 6, which has been referred to as a sexadecimal system. A number was decomposed as follows:
Using the earlier example
Unlike the general case which can be used to represent any number no matter how large, the Sumerian system stopped at 12960000. Indeed this was a highly significant number to them, similar to our infinity.
Square Root AlgorithmsWritten by Paul BourkeInteresting solution to finding the sqrt of an integer
Add up all the odd numbers from 1 while the sum is less than
or equal to the number whose square root is being sought. The
number of odd numbers needed is the square root.
1 + 3 + 5 + 7 = 16 1 + 3 + 5 + 7 + 9 = 25
Algorithm example long sqrt(r) long r; { long t,b,c=0; for (b=0x10000000;b!=0;b>>=2) { t = c + b; c >>= 1; if (t <= r) { r -= t; c += b; } } return(c); }Contribution by Lionel Dangerfield
I recently noted your site that addressed finding the integer square root of a number using the fact that the sum of the first N odd numbers is N^2. Were you aware a modification of this method can be used to obtain the actual square root of any number? I used this method (source unknown) some 45 years ago using a "hand crank" mechanical calculator to which this method was easily accommodated. I have searched the web for documentation of this method and yours was the closest one found. It is, of course, totally useless today but, nevertheless somewhat interesting or perhaps amusing. Assuming that you may have an interest, note the following: There is actually a series of correlated subtractions; the first determines the digit(s) to the left of the decimal point. The second the first digit to the right, the third the second digit to the right, etc. SERIES I: If N is the number, start by subtracting the odd numbers 1,3,5,7,9 etc. from N until the remainder (R) after a subtraction is less than the next odd number in sequence. At that point, the number of subtractions is equal to the digit(s) of the square root to the left of the decimal point. SERIES II: To begin the next series, multiply the current remainder (R) by 10 and fix the first odd number to be used in this series equal to the last used odd number in the previous series plus 1.1 and continue as noted above. When the remainder (R) is again less than the next odd number in sequence, the first digit to the right of the decimal point is equal to the number of subtractions in that series. SERIES III: Next again multiply the remainder (R) by 10 and fix the next odd number as the last odd number used plus (this time) 0.11. Continue as noted above except in the next series add 0,011 to the last used odd number. In the next series add 0.0011 etc. This narrative sounds much more complex than it should. Note the following: EXAMPLE:Find the sq. root of 28.5156 Series I 28.5156 - ( 1+3+5+7+9) = 3.5156 Five subtractions so the first digit is 5 Note the next odd number , 11, is > 3.5156
Series II
Series III
This method appears to work for as many decimal places as you wish to carry it out. I have no clue as to why this appears to work. Happy NumbersWritten by Paul BourkeDecember 2017
The happy status of a number is determined by repeatedly replacing the number by the sum of the square of its digits. If this sequence ends in a 1 then the number is said to be happy, if it never reaches 1 it is unhappy. 1 is obviously a happy number. The next happy number is 7. The sequence that determines that state is 7, 49 (72), 97 (42+92), 130 (92+72), 10 (12+32), 1 The happy numbers less than 10,000 are as follows, there are 1442 of them. 1 7 10 13 19 23 28 31 32 44 49 68 70 79 82 86 91 94 97 100 103 109 129 130 133 139 167 176 188 190 192 193 203 208 219 226 230 236 239 262 263 280 291 293 301 302 310 313 319 320 326 329 331 338 356 362 365 367 368 376 379 383 386 391 392 397 404 409 440 446 464 469 478 487 490 496 536 556 563 565 566 608 617 622 623 632 635 637 638 644 649 653 655 656 665 671 673 680 683 694 700 709 716 736 739 748 761 763 784 790 793 802 806 818 820 833 836 847 860 863 874 881 888 899 901 904 907 910 912 913 921 923 931 932 937 940 946 964 970 973 989 998 1000 1003 1009 1029 1030 1033 1039 1067 1076 1088 1090 1092 1093 1112 1114 1115 1121 1122 1125 1128 1141 1148 1151 1152 1158 1177 1182 1184 1185 1188 1209 1211 1212 1215 1218 1221 1222 1233 1247 1251 1257 1258 1274 1275 1277 1281 1285 1288 1290 1299 1300 1303 1309 1323 1330 1332 1333 1335 1337 1339 1353 1366 1373 1390 1393 1411 1418 1427 1444 1447 1448 1457 1472 1474 1475 1478 1481 1484 1487 1511 1512 1518 1521 1527 1528 1533 1547 1557 1572 1574 1575 1578 1581 1582 1587 1599 1607 1636 1663 1666 1670 1679 1697 1706 1717 1724 1725 1727 1733 1742 1744 1745 1748 1752 1754 1755 1758 1760 1769 1771 1772 1784 1785 1796 1808 1812 1814 1815 1818 1821 1825 1828 1841 1844 1847 1851 1852 1857 1874 1875 1880 1881 1882 1888 1900 1902 1903 1920 1929 1930 1933 1959 1967 1976 1992 1995 2003 2008 2019 2026 2030 2036 2039 2062 2063 2080 2091 2093 2109 2111 2112 2115 2118 2121 2122 2133 2147 2151 2157 2158 2174 2175 2177 2181 2185 2188 2190 2199 2206 2211 2212 2221 2224 2242 2245 2254 2257 2258 2260 2275 2285 2300 2306 2309 2313 2331 2333 2338 2339 2360 2369 2383 2390 2393 2396 2417 2422 2425 2448 2452 2455 2457 2458 2471 2475 2478 2484 2485 2487 2511 2517 2518 2524 2527 2528 2542 2545 2547 2548 2554 2555 2557 2568 2571 2572 2574 2575 2581 2582 2584 2586 2602 2603 2620 2630 2639 2658 2685 2693 2714 2715 2717 2725 2741 2745 2748 2751 2752 2754 2755 2771 2784 2800 2811 2815 2818 2825 2833 2844 2845 2847 2851 2852 2854 2856 2865 2874 2881 2899 2901 2903 2910 2919 2930 2933 2936 2963 2989 2991 2998 3001 3002 3010 3013 3019 3020 3026 3029 3031 3038 3056 3062 3065 3067 3068 3076 3079 3083 3086 3091 3092 3097 3100 3103 3109 3123 3130 3132 3133 3135 3137 3139 3153 3166 3173 3190 3193 3200 3206 3209 3213 3231 3233 3238 3239 3260 3269 3283 3290 3293 3296 3301 3308 3310 3312 3313 3315 3317 3319 3321 3323 3328 3329 3331 3332 3338 3346 3351 3355 3356 3364 3365 3367 3371 3376 3380 3382 3383 3391 3392 3436 3456 3463 3465 3466 3506 3513 3531 3535 3536 3546 3553 3560 3563 3564 3602 3605 3607 3608 3616 3620 3629 3634 3635 3637 3643 3645 3646 3650 3653 3654 3661 3664 3667 3670 3673 3676 3680 3689 3692 3698 3706 3709 3713 3731 3736 3760 3763 3766 3779 3789 3790 3797 3798 3803 3806 3823 3830 3832 3833 3860 3869 3879 3896 3897 3901 3902 3907 3910 3913 3920 3923 3926 3931 3932 3962 3968 3970 3977 3978 3986 3987 4004 4009 4040 4046 4064 4069 4078 4087 4090 4096 4111 4118 4127 4144 4147 4148 4157 4172 4174 4175 4178 4181 4184 4187 4217 4222 4225 4248 4252 4255 4257 4258 4271 4275 4278 4284 4285 4287 4336 4356 4363 4365 4366 4400 4406 4414 4417 4418 4428 4441 4447 4449 4455 4460 4471 4474 4477 4481 4482 4494 4517 4522 4525 4527 4528 4536 4545 4552 4554 4555 4558 4563 4571 4572 4577 4582 4585 4599 4604 4609 4633 4635 4636 4640 4653 4663 4690 4708 4712 4714 4715 4718 4721 4725 4728 4741 4744 4747 4751 4752 4757 4774 4775 4780 4781 4782 4788 4807 4811 4814 4817 4824 4825 4827 4841 4842 4852 4855 4870 4871 4872 4878 4887 4888 4900 4906 4944 4959 4960 4995 5036 5056 5063 5065 5066 5111 5112 5118 5121 5127 5128 5133 5147 5157 5172 5174 5175 5178 5181 5182 5187 5199 5211 5217 5218 5224 5227 5228 5242 5245 5247 5248 5254 5255 5257 5268 5271 5272 5274 5275 5281 5282 5284 5286 5306 5313 5331 5335 5336 5346 5353 5360 5363 5364 5417 5422 5425 5427 5428 5436 5445 5452 5454 5455 5458 5463 5471 5472 5477 5482 5485 5499 5506 5517 5524 5525 5527 5533 5542 5544 5545 5548 5552 5554 5555 5558 5560 5569 5571 5572 5584 5585 5596 5603 5605 5606 5628 5630 5633 5634 5643 5650 5659 5660 5666 5682 5695 5712 5714 5715 5718 5721 5722 5724 5725 5741 5742 5747 5751 5752 5774 5781 5789 5798 5799 5811 5812 5817 5821 5822 5824 5826 5842 5845 5854 5855 5862 5871 5879 5897 5919 5949 5956 5965 5978 5979 5987 5991 5994 5997 6008 6017 6022 6023 6032 6035 6037 6038 6044 6049 6053 6055 6056 6065 6071 6073 6080 6083 6094 6107 6136 6163 6166 6170 6179 6197 6202 6203 6220 6230 6239 6258 6285 6293 6302 6305 6307 6308 6316 6320 6329 6334 6335 6337 6343 6345 6346 6350 6353 6354 6361 6364 6367 6370 6373 6376 6380 6389 6392 6398 6404 6409 6433 6435 6436 6440 6453 6463 6490 6503 6505 6506 6528 6530 6533 6534 6543 6550 6559 6560 6566 6582 6595 6605 6613 6616 6631 6634 6637 6643 6650 6656 6661 6665 6673 6701 6703 6710 6719 6730 6733 6736 6763 6789 6791 6798 6800 6803 6825 6830 6839 6852 6879 6893 6897 6899 6904 6917 6923 6932 6938 6940 6955 6971 6978 6983 6987 6989 6998 7000 7009 7016 7036 7039 7048 7061 7063 7084 7090 7093 7106 7117 7124 7125 7127 7133 7142 7144 7145 7148 7152 7154 7155 7158 7160 7169 7171 7172 7184 7185 7196 7214 7215 7217 7225 7241 7245 7248 7251 7252 7254 7255 7271 7284 7306 7309 7313 7331 7336 7360 7363 7366 7379 7389 7390 7397 7398 7408 7412 7414 7415 7418 7421 7425 7428 7441 7444 7447 7451 7452 7457 7474 7475 7480 7481 7482 7488 7512 7514 7515 7518 7521 7522 7524 7525 7541 7542 7547 7551 7552 7574 7581 7589 7598 7599 7601 7603 7610 7619 7630 7633 7636 7663 7689 7691 7698 7711 7712 7721 7739 7744 7745 7754 7788 7793 7804 7814 7815 7824 7839 7840 7841 7842 7848 7851 7859 7869 7878 7884 7887 7893 7895 7896 7900 7903 7916 7930 7937 7938 7958 7959 7961 7968 7973 7983 7985 7986 7995 8002 8006 8018 8020 8033 8036 8047 8060 8063 8074 8081 8088 8099 8108 8112 8114 8115 8118 8121 8125 8128 8141 8144 8147 8151 8152 8157 8174 8175 8180 8181 8182 8188 8200 8211 8215 8218 8225 8233 8244 8245 8247 8251 8252 8254 8256 8265 8274 8281 8299 8303 8306 8323 8330 8332 8333 8360 8369 8379 8396 8397 8407 8411 8414 8417 8424 8425 8427 8441 8442 8452 8455 8470 8471 8472 8478 8487 8488 8511 8512 8517 8521 8522 8524 8526 8542 8545 8554 8555 8562 8571 8579 8597 8600 8603 8625 8630 8639 8652 8679 8693 8697 8699 8704 8714 8715 8724 8739 8740 8741 8742 8748 8751 8759 8769 8778 8784 8787 8793 8795 8796 8801 8808 8810 8811 8812 8818 8821 8847 8848 8874 8877 8880 8881 8884 8909 8929 8936 8937 8957 8963 8967 8969 8973 8975 8976 8990 8992 8996 9001 9004 9007 9010 9012 9013 9021 9023 9031 9032 9037 9040 9046 9064 9070 9073 9089 9098 9100 9102 9103 9120 9129 9130 9133 9159 9167 9176 9192 9195 9201 9203 9210 9219 9230 9233 9236 9263 9289 9291 9298 9301 9302 9307 9310 9313 9320 9323 9326 9331 9332 9362 9368 9370 9377 9378 9386 9387 9400 9406 9444 9459 9460 9495 9519 9549 9556 9565 9578 9579 9587 9591 9594 9597 9604 9617 9623 9632 9638 9640 9655 9671 9678 9683 9687 9689 9698 9700 9703 9716 9730 9737 9738 9758 9759 9761 9768 9773 9783 9785 9786 9795 9809 9829 9836 9837 9857 9863 9867 9869 9873 9875 9876 9890 9892 9896 9908 9912 9915 9921 9928 9945 9951 9954 9957 9968 9975 9980 9982 9986 10000 There are a few obvious things to be noted from the definition. For example, the order of the digits does not matter, so since 9908 is happy then so is 8099, 998, 989, 899, 9809, 9089. Also, zeros don't play any part in the happiness. So since 9001 is happy, so is 901, 109, 19, 91. It turns out that the sequence for all unhappy numbers falls into the attractor repeating sequences 4, 16, 37, 58, 89, 145, 42, 20. long IsHappy(long n) { long i; long digit,sum; for (i=0;i<NMAX;i++) { sum = 0; while (n != 0) { digit = n % 10; sum += digit*digit; n /= 10; } if (sum <= 1) return(i); n = sum; } return(NMAX); } The concept can be extended to higher powers. The happy numbers (only 101 of them) under 10,000 for a third power are 1 10 100 112 121 211 778 787 877 1000 1012 1021 1102 1120 1189 1198 1201 1210 1234 1243 1324 1342 1423 1432 1579 1597 1759 1795 1819 1891 1918 1957 1975 1981 2011 2101 2110 2134 2143 2314 2341 2413 2431 2779 2797 2977 3124 3142 3214 3241 3412 3421 4123 4132 4213 4231 4312 4321 5179 5197 5719 5791 5917 5971 7078 7087 7159 7195 7279 7297 7519 7591 7708 7729 7780 7792 7807 7870 7915 7927 7951 7972 8077 8119 8191 8707 8770 8911 9118 9157 9175 9181 9277 9517 9571 9715 9727 9751 9772 9811 10000. In general as the power increases the frequency of happy numbers decreases. Another variation is to compute the lucky numbers for other bases, base 10 being used above. For base 2 and 4 all numbers are lucky, they are therefore called lucky bases. For base 3 the happy or unhappy status is the same as the even or odd status. Hazy PrimesWritten by Paul BourkeInspired by Roy Blatchford, see original document December 2017
A hazy prime of base "b" is a positive whole number that is not divisible (without remainder) by the first b prime numbers. The n'th hazy prime is denoted as Hb,n. So for example the sequence of hazy primes H1,n are all the positive whole numbers not divisible by 2, namely the odd numbers. The sequence H2,n are all the positive whole numbers not divisible by 2 and 3. The sequence up to 100 being 1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49 53 55 59 61 65 67 71 73 77 79 83 85 89 91 95 97. The sequence up to 200 for H3,n is 1 7 11 13 17 19 23 29 31 37 41 43 47 49 53 59 61 67 71 73 77 79 83 89 91 97 101 103 107 109 113 119 121 127 131 133 137 139 143 149 151 157 161 163 167 169 173 179 181 187 191 193 197 199 The following table shows the base b on the vertical access and the hazy prime sequence on the horizontal axis. The base extends to 200 and the first 2000 items in the sequence shown. The red lines or spheres are primes.
|