How to resolve the algorithm Van Eck sequence step by step in the zkl programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Van Eck sequence step by step in the zkl programming language
Table of Contents
Problem Statement
The sequence is generated by following this pseudo-code:
Using A: Using B: Using C: Using B: Using C: (zero last occurred two steps back - before the one) Using B: Using C: (two last occurred two steps back - before the zero) Using C: (two last occurred one step back) Using C: (one last appeared six steps back) ...
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Van Eck sequence step by step in the zkl programming language
Source code in the zkl programming language
fcn vanEck(startAt=0){ // --> iterator
(startAt).walker(*).tweak(fcn(n,seen,rprev){
prev,t := rprev.value, n - seen.find(prev,n);
seen[prev] = n;
rprev.set(t);
t
}.fp1(Dictionary(),Ref(startAt))).push(startAt)
}
foreach n in (9){
ve:=vanEck(n);
println("The first ten terms of the Van Eck (%d) sequence are:".fmt(n));
println("\t",ve.walk(10).concat(","));
println(" Terms 991 to 1000 of the sequence are:");
println("\t",ve.drop(990-10).walk(10).concat(","));
}
You may also check:How to resolve the algorithm Abundant, deficient and perfect number classifications step by step in the R programming language
You may also check:How to resolve the algorithm Calendar step by step in the Python programming language
You may also check:How to resolve the algorithm Compound data type step by step in the AWK programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the Qi programming language
You may also check:How to resolve the algorithm Integer comparison step by step in the Sparkling programming language