How to resolve the algorithm Deceptive numbers step by step in the langur programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Deceptive numbers step by step in the langur programming language

Table of Contents

Problem Statement

Repunits are numbers that consist entirely of repetitions of the digit one (unity). The notation Rn symbolizes the repunit made up of n ones. Every prime p larger than 5, evenly divides the repunit Rp-1.

The repunit R6 is evenly divisible by 7. 111111 / 7 = 15873 The repunit R42 is evenly divisible by 43. 111111111111111111111111111111111111111111 / 43 = 2583979328165374677002583979328165374677 And so on.

There are composite numbers that also have this same property. They are often referred to as deceptive non-primes or deceptive numbers.

The repunit R90 is evenly divisible by the composite number 91 (=7*13).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Deceptive numbers step by step in the langur programming language

Source code in the langur programming language

val .isPrime = f .i == 2 or .i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2

var .nums = []
var .repunit = 111_111

for .n = 9; len(.nums) < 10; .n += 2 {
    .repunit = .repunit x 100 + 11
    if not .isPrime(.n) and .repunit div .n {
        .nums = more .nums, .n
    }
}

writeln .nums

  

You may also check:How to resolve the algorithm Cumulative standard deviation step by step in the Perl programming language
You may also check:How to resolve the algorithm Date format step by step in the Yabasic programming language
You may also check:How to resolve the algorithm Polynomial regression step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm The Twelve Days of Christmas step by step in the PureBasic programming language
You may also check:How to resolve the algorithm World Cup group stage step by step in the Erlang programming language