How to resolve the algorithm Curzon numbers step by step in the Raku programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Curzon numbers step by step in the Raku programming language

Table of Contents

Problem Statement

A Curzon number is defined to be a positive integer n for which 2n + 1 is evenly divisible by 2 × n + 1. Generalized Curzon numbers are those where the positive integer n, using a base integer k, satisfy the condition that kn + 1 is evenly divisible by k × n + 1. Base here does not imply the radix of the counting system; rather the integer the equation is based on. All calculations should be done in base 10. Generalized Curzon numbers only exist for even base integers.

and even though it is not specifically mentioned that they are Curzon numbers:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Curzon numbers step by step in the Raku programming language

Source code in the raku programming language

sub curzon ($base) { lazy (1..∞).hyper.map: { $_ if (exp($_, $base) + 1) %% ($base × $_ + 1) } };

for <2 4 6 8 10> {
    my $curzon = .&curzon;
    say "\nFirst 50 Curzon numbers using a base of $_:\n" ~
      $curzon[^50].batch(10)».fmt("%4s").join("\n") ~
      "\nOne thousandth: " ~ $curzon[999]
}


  

You may also check:How to resolve the algorithm Factors of an integer step by step in the RPL programming language
You may also check:How to resolve the algorithm Numbers which are the cube roots of the product of their proper divisors step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Random numbers step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Hello world/Newbie step by step in the PepsiScript programming language
You may also check:How to resolve the algorithm Roman numerals/Decode step by step in the 360 Assembly programming language