How to resolve the algorithm Anti-primes step by step in the zkl programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Anti-primes step by step in the zkl programming language
Table of Contents
Problem Statement
The anti-primes (or highly composite numbers, sequence A002182 in the OEIS) are the natural numbers with more factors than any smaller than itself.
Generate and show here, the first twenty anti-primes.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Anti-primes step by step in the zkl programming language
Source code in the zkl programming language
fcn properDivsN(n) //--> count of proper divisors. 1-->1, wrong but OK here
{ [1.. (n + 1)/2 + 1].reduce('wrap(p,i){ p + (n%i==0 and n!=i) }) }
fcn antiPrimes{ // -->iterator
Walker.chain([2..59],[60..*,30]).tweak(fcn(c,rlast){
last,mx := rlast.value, properDivsN(c);
if(mx<=last) return(Void.Skip);
rlast.set(mx);
c
}.fp1(Ref(0))).push(1); // 1 has no proper divisors
}
println("First 20 anti-primes:\n ",antiPrimes().walk(20).concat(" "));
You may also check:How to resolve the algorithm Temperature conversion step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Gauss-Jordan matrix inversion step by step in the Raku programming language
You may also check:How to resolve the algorithm Levenshtein distance step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the C++ programming language
You may also check:How to resolve the algorithm CSV to HTML translation step by step in the Common Lisp programming language