How to resolve the algorithm Taxicab numbers step by step in the PicoLisp programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Taxicab numbers step by step in the PicoLisp programming language

Table of Contents

Problem Statement

A   taxicab number   (the definition that is being used here)   is a positive integer that can be expressed as the sum of two positive cubes in more than one way.

The first taxicab number is   1729,   which is:

Taxicab numbers are also known as:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Taxicab numbers step by step in the PicoLisp programming language

Source code in the picolisp programming language

(load "@lib/simul.l")

(off 'B)
(for L (subsets 2 (range 1 1200))
   (let K (sum '((N) (** N 3)) L)
      (ifn (lup B K)
         (idx 'B (list K 1 (list L)) T)
         (inc (cdr @))
         (push (cddr @) L) ) ) )
(setq R
   (filter
      '((L) (>= (cadr L) 2))
      (idx 'B)) )
(for L (head 25 R)
   (println (car L) (caddr L)) )
(for L (head 7 (nth R 2000))
   (println (car L) (caddr L)) )

  

You may also check:How to resolve the algorithm Ulam spiral (for primes) step by step in the Scala programming language
You may also check:How to resolve the algorithm Middle three digits step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm List comprehensions step by step in the REXX programming language
You may also check:How to resolve the algorithm Call an object method step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Named parameters step by step in the V (Vlang) programming language