How to resolve the algorithm Numbers which are the cube roots of the product of their proper divisors step by step in the Forth programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Numbers which are the cube roots of the product of their proper divisors step by step in the Forth programming language

Table of Contents

Problem Statement

Consider the number 24. Its proper divisors are: 1, 2, 3, 4, 6, 8 and 12. Their product is 13,824 and the cube root of this is 24. So 24 satisfies the definition in the task title. Compute and show here the first 50 positive integers which are the cube roots of the product of their proper divisors. Also show the 500th and 5,000th such numbers. Compute and show the 50,000th such number. OEIS considers 1 to be the first number in this sequence even though, strictly speaking, it has no proper divisors. Please therefore do likewise.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Numbers which are the cube roots of the product of their proper divisors step by step in the Forth programming language

Source code in the forth programming language

500000 constant limit
variable pdc limit cells allot

: main
  limit 0 do
    1 pdc i cells + !
  loop
  7 pdc !
  limit 2 +do
    limit i 2* 1- +do
      1 pdc i cells + +!
    j +loop
  loop
  ." First 50 numbers which are the cube roots" cr
  ." of the products of their proper divisors:" cr
  500 0
  limit 0 do
    pdc i cells + @ 7 = if
      1+
      dup 50 <= if
        i 1+ 3 .r
        dup 10 mod 0= if cr else space then
      else
        2dup = if
          cr over 5 .r ." th: " i 1+ .
          swap 10 * swap
        then
      then
    then
  loop
  2drop cr ;

main
bye


  

You may also check:How to resolve the algorithm Random number generator (included) step by step in the Factor programming language
You may also check:How to resolve the algorithm Kronecker product step by step in the Action! programming language
You may also check:How to resolve the algorithm Odd word problem step by step in the Run BASIC programming language
You may also check:How to resolve the algorithm Ramer-Douglas-Peucker line simplification step by step in the Rust programming language
You may also check:How to resolve the algorithm Loops/While step by step in the Picat programming language