How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the Raku 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 Raku 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 Raku programming language

Source code in the raku programming language

sub div-count (\x) {
    return 2 if x.is-prime;
    +flat (1 .. x.sqrt.floor).map: -> \d {
        unless x % d { my \y = x div d; y == d ?? y !! (y, d) }
    }
}

my $limit = 15;

my $m = 1;
put "First $limit terms of OEIS:A069654";
put (1..$limit).map: -> $n { my $ = $m = first { $n == .&div-count }, $m..Inf };


  

You may also check:How to resolve the algorithm Floyd-Warshall algorithm step by step in the Sidef programming language
You may also check:How to resolve the algorithm Strip comments from a string step by step in the Erlang programming language
You may also check:How to resolve the algorithm Loops/For step by step in the Elixir programming language
You may also check:How to resolve the algorithm 4-rings or 4-squares puzzle step by step in the MiniScript programming language
You may also check:How to resolve the algorithm Check that file exists step by step in the Perl programming language