Hickerson series of almost integers: Difference between revisions

Content added Content deleted
m (→‎version 2: changed height of the output section window.)
m (→‎version 2: added whitespace, simplified the wording in the REXX section header.)
Line 1,806: Line 1,806:
===version 2===
===version 2===
This REXX version can calculate the Hickerson series to any number up to the length (in decimal digits)
This REXX version can calculate the Hickerson series to any number up to the length (in decimal digits)
<br>up to the size &nbsp; (the number of decimal digits) &nbsp; of the number &nbsp; (the number of decimal digits) &nbsp; returned by the &nbsp; '''ln2''' &nbsp; function.
<br>of the number returned by the &nbsp; '''ln2''' &nbsp; function.


This version supports up to &nbsp; '''507''' &nbsp; decimal digits.
This version supports up to &nbsp; '''507''' &nbsp; decimal digits.
<lang rexx>/*REXX program to calculate and show the Hickerson series (are near integer). */
<lang rexx>/*REXX program to calculate and show the Hickerson series (are near integer). */
numeric digits length(ln2()) - 1 /*be able to calculate big factorials. */
numeric digits length(ln2())-length(.) /*be able to calculate big factorials. */
parse arg N . /*get optional number of values to use.*/
parse arg N . /*get optional number of values to use.*/
if N=='' then N=18 /*Not specified? Then use the default.*/
if N=='' then N= 1 /*Not specified? Then use the default.*/
/* [↓] compute possible Hickerson #s. */
/* [↓] compute possible Hickerson #s. */
do j=1 for N; #=Hickerson(j) /*traipse thru a range of Hickerson #s.*/
do j=1 for N; #= Hickerson(j) /*traipse thru a range of Hickerson #s.*/
?=right(#*10%1, 1) /*get 1st decimal digit past dec. point*/
?= right(# * 10 % 1, 1) /*get 1st decimal digit past dec. point*/
if ?==0 | ?==9 then _= 'almost integer' /*the number is, */
if ?==0 | ?==9 then _= 'almost integer' /*the number is, */
else _= ' ' /* or it ain't. */
else _= ' ' /* or it ain't. */
say right(j,3) _ format(#,,5) /*show number with 5 dec digs fraction.*/
say right(j,3) _ format(#, , 5) /*show number with 5 dec digs fraction.*/
end /*j*/
end /*j*/
exit /*stick a fork in it, we're all done. */
exit /*stick a fork in it, we're all done. */
/*─────────────────────────────────────────────────────────────────────────────────────────────────────────*/
/*─────────────────────────────────────────────────────────────────────────────────────────────────────────*/
!: procedure; parse arg x; !=1; do j=2 to x; !=!*j; end; return ! /* ◄──compute X factorial*/
!: procedure; parse arg x; !=1; do j=2 to x; != !*j; end; return ! /* ◄──compute X factorial*/
Hickerson: procedure; parse arg z; return !(z) / (2*ln2() ** (z+1))
Hickerson: procedure; parse arg z; return !(z) / (2*ln2() ** (z+1))
ln2: return .69314718055994530941723212145817656807550013436025525412068000949339362196969471560586332699641,
ln2: return .69314718055994530941723212145817656807550013436025525412068000949339362196969471560586332699641,
|| 8687542001481020570685733685520235758130557032670751635075961930727570828371435190307038623891673471123,
|| 8687542001481020570685733685520235758130557032670751635075961930727570828371435190307038623891673471123,