How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the F# programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the F# programming language

Table of Contents

Problem Statement

Calculate the sequence where each term an is the smallest natural number greater than the previous term, that has exactly n divisors.

Show here, on this page, at least the first 15 terms of the sequence.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the F# programming language

Source code in the fsharp programming language

// Nigel Galloway: November 19th., 2017
let fN g=[1..(float>>sqrt>>int)g]|>List.fold(fun Σ n->if g%n>0 then Σ else if g/n=n then Σ+1 else Σ+2) 0
let A069654=let rec fG n g=seq{match g-fN n with 0->yield n; yield! fG(n+1)(g+1) |_->yield! fG(n+1)g} in fG 1 1

A069654 |> Seq.take 28|>Seq.iter(printf "%d "); printfn ""


  

You may also check:How to resolve the algorithm Primality by trial division step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the AWK programming language
You may also check:How to resolve the algorithm String concatenation step by step in the Elixir programming language
You may also check:How to resolve the algorithm Sorting algorithms/Bubble sort step by step in the 6502 Assembly programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Modula-3 programming language