How to resolve the algorithm Hickerson series of almost integers step by step in the D programming language
How to resolve the algorithm Hickerson series of almost integers step by step in the D programming language
Table of Contents
Problem Statement
The following function, due to D. Hickerson, is said to generate "Almost integers" by the "Almost Integer" page of Wolfram MathWorld, (December 31 2013). (See formula numbered 51.)
The function is:
h ( n )
n !
2 ( ln
2
)
n + 1
{\displaystyle h(n)={\operatorname {n} ! \over 2(\ln {2})^{n+1}}}
It is said to produce "almost integers" for n between 1 and 17.
The purpose of the task is to verify this assertion.
Assume that an "almost integer" has either a nine or a zero as its first digit after the decimal point of its decimal string representation
Calculate all values of the function checking and stating which are "almost integers". Note: Use extended/arbitrary precision numbers in your calculation if necessary to ensure you have adequate precision of results as for example:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Hickerson series of almost integers step by step in the D programming language
Source code in the d programming language
void main() {
import std.stdio, std.algorithm, std.mathspecial;
foreach (immutable n; 1 .. 18) {
immutable x = gamma(n + 1) / (2 * LN2 ^^ (n + 1)),
tenths = cast(int)floor((x - x.floor) * 10);
writefln("H(%2d)=%22.2f is %snearly integer.", n, x,
tenths.among!(0, 9) ? "" : "NOT ");
}
}
You may also check:How to resolve the algorithm HTTP step by step in the VBScript programming language
You may also check:How to resolve the algorithm Middle three digits step by step in the COBOL programming language
You may also check:How to resolve the algorithm Monads/Maybe monad step by step in the Go programming language
You may also check:How to resolve the algorithm Five weekends step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Create a two-dimensional array at runtime step by step in the Smalltalk programming language