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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Duffinian numbers step by step in the Quackery 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 Quackery programming language

Source code in the quackery programming language

  [ dup factors
    dup size 3 < iff
      [ 2drop false ] done
    0 swap witheach +
    gcd 1 = ]              is duffinian ( n --> b )

  [] 0
  [ dup duffinian if
      [ tuck join swap ]
    1+
    over size 50 = until ]
  drop
  [] swap
  witheach
    [ number$ nested join ]
  60 wrap$
  cr cr
  0 temp put
  [] 0
  [ dup duffinian iff
      [ 1 temp tally ]
    else
      [ 0 temp replace ]
    temp share 2 > if
      [ tuck 2 -
        join swap ]
    1+
    over size 15 = until ]
  drop
  [] swap
  witheach
    [ dup 1+ dup 1+
      join join
      nested join ]
  witheach [ echo cr ]

  

You may also check:How to resolve the algorithm Damm algorithm step by step in the C programming language
You may also check:How to resolve the algorithm Strip a set of characters from a string step by step in the APL programming language
You may also check:How to resolve the algorithm Palindrome detection step by step in the MiniScript programming language
You may also check:How to resolve the algorithm Show ASCII table step by step in the Cowgol programming language
You may also check:How to resolve the algorithm Function composition step by step in the Fōrmulæ programming language