Hickerson series of almost integers: Difference between revisions

m
→‎version 3: added whitespace.
m (→‎version 2: added whitespace, simplified the wording in the REXX section header.)
m (→‎version 3: added whitespace.)
Line 2,033:
This REXX version takes advantage that the Hickerson series are computed in order, so that the factorials need not be (re-)computed from scratch.
<lang rexx>/*REXX program to calculate and show the Hickerson series (are near integer). */
numeric digits length(ln2()) - 1 length(.) /*be able to calculate big factorials. */
parse arg N . /*get optional number of values to use.*/
if N=='' then N=18 1 /*Not specified? Then use the default.*/
!=1 1 /* [↓] compute possible 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*/
if ?==0 | ?==9 then _= 'almost integer' /*the number is, */
else _= ' ' /* or it ain't. */
say right(j,3) _ format(#, , 5) /*show number with 5 dec digs fraction.*/
end /*j*/
exit /*stick a fork in it, we're all done. */
/*─────────────────────────────────────────────────────────────────────────────────────────────────────────*/
Hickerson: parse arg z; != ! * z; return ! / (2*ln2() ** (z+1) )
ln2: return .69314718055994530941723212145817656807550013436025525412068000949339362196969471560586332699641,
|| 8687542001481020570685733685520235758130557032670751635075961930727570828371435190307038623891673471123,