How to resolve the algorithm Hickerson series of almost integers step by step in the Racket programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Hickerson series of almost integers step by step in the Racket 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 Racket programming language

Source code in the racket programming language

#lang racket
(require math/bigfloat)

(define (hickerson n)
 (bf/ (bffactorial n)
      2.bf
      (bfexpt (bflog 2.bf) (bf (+ n 1)))))
 
(for ([n (in-range 18)])
  (define hickerson-n (hickerson n))
  (define first-decimal 
    (bigfloat->integer (bftruncate (bf* 10.bf (bffrac hickerson-n)))))
  (define almost-integer (if (or (= first-decimal 0) (= first-decimal 9))
                           "is Nearly integer" 
                           "is not Nearly integer!")) 
  (printf "~a: ~a ~a\n" 
          (~r n #:min-width 2) 
          (bigfloat->string hickerson-n) 
          almost-integer))


  

You may also check:How to resolve the algorithm 21 game step by step in the Pascal programming language
You may also check:How to resolve the algorithm Ray-casting algorithm step by step in the Ada programming language
You may also check:How to resolve the algorithm Word wrap step by step in the Commodore BASIC programming language
You may also check:How to resolve the algorithm Long multiplication step by step in the Fortran programming language
You may also check:How to resolve the algorithm Exceptions/Catch an exception thrown in a nested call step by step in the Seed7 programming language