How to resolve the algorithm Duffinian numbers step by step in the Maxima programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Duffinian numbers step by step in the Maxima programming language

Table of Contents

Problem Statement

A Duffinian number is a composite number k that is relatively prime to its sigma sum σ. The sigma sum of k is the sum of the divisors of k.

161 is a Duffinian number.

Duffinian numbers are very common. It is not uncommon for two consecutive integers to be Duffinian (a Duffinian twin) (8, 9), (35, 36), (49, 50), etc. Less common are Duffinian triplets; three consecutive Duffinian numbers. (63, 64, 65), (323, 324, 325), etc. Much, much less common are Duffinian quadruplets and quintuplets. The first Duffinian quintuplet is (202605639573839041, 202605639573839042, 202605639573839043, 202605639573839044, 202605639573839045). It is not possible to have six consecutive Duffinian numbers

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Duffinian numbers step by step in the Maxima programming language

Source code in the maxima programming language

/* Predicate functions that checks wether an integer is a Duffinian number or not */
duffinianp(n):=if n#1 and not primep(n) and gcd(n,divsum(n))=1 then true$

/* Function that returns a list of the first len Duffinian numbers */
duffinian_count(len):=block(
    [i:1,count:0,result:[]],
    while count
    result)$

/* Function that returns a list of the first len Duffinian triples */
duffinian_triples_count(len):=block(
    [i:1,count:0,result:[]],
    while count
    result)$

/* Test cases */
/* First 50 Duffinian numbers */
duffinian_count(50);

/* First 15 Duffinian triples */
duffinian_triples_count(15);


  

You may also check:How to resolve the algorithm Fractal tree step by step in the Frink programming language
You may also check:How to resolve the algorithm Binary digits step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm Arithmetic derivative step by step in the Rust programming language
You may also check:How to resolve the algorithm Determine if a string is numeric step by step in the Pike programming language
You may also check:How to resolve the algorithm Call a function step by step in the Lingo programming language