How to resolve the algorithm Numbers which are the cube roots of the product of their proper divisors step by step in the XPL0 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 XPL0 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 XPL0 programming language

Source code in the xpl0 programming language

func DivisorCount(N);           \Return count of divisors
int N, Total, P, Count;
[Total:= 1;
while (N&1) = 0 do
    [Total:= Total+1;
    N:= N>>1;
    ];
P:= 3;
while P*P <= N do
    [Count:= 1;
    while rem(N/P) = 0 do
        [Count:= Count+1;
        N:= N/P;
        ];
    Total:= Total*Count;
    P:= P+2;
    ];
if N > 1 then
    Total:= Total*2;
return Total;
];

int N, Count;
[Text(0, "First 50 numbers which are the cube roots of the products of ");
 Text(0, "their proper divisors:^m^j");
N:= 1;  Count:= 0;
repeat  if N = 1 or DivisorCount(N) = 8 then
            [Count:= Count+1;
            if Count <= 50 then
                [Format(4, 0);
                RlOut(0, float(N));
                if rem(Count/10) = 0 then CrLf(0);
                ]
            else if Count = 500 or Count = 5000 or Count = 50000 then
                [Format(6, 0);
                RlOut(0, float(Count));
                Text(0, "th: ");
                IntOut(0, N);
                CrLf(0);
                ];
            ];                  
        N:= N+1;
until   Count >= 50000;
]

  

You may also check:How to resolve the algorithm Vampire number step by step in the Wren programming language
You may also check:How to resolve the algorithm Matrix chain multiplication step by step in the Fortran programming language
You may also check:How to resolve the algorithm Temperature conversion step by step in the Plain English programming language
You may also check:How to resolve the algorithm Animation step by step in the E programming language
You may also check:How to resolve the algorithm Pseudo-random numbers/Middle-square method step by step in the Lambdatalk programming language