How to resolve the algorithm Numbers which are the cube roots of the product of their proper divisors step by step in the FreeBASIC 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 FreeBASIC 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 FreeBASIC programming language
Source code in the freebasic programming language
Dim As Single limite = 500000
Dim As Integer pdc(1 To limite)
Dim As Integer i, j
For i = 1 To Ubound(pdc)
pdc(i) = 1
Next i
pdc(1) = 7
For i = 2 To Ubound(pdc)
For j = i + i To Ubound(pdc) Step i
pdc(j) += 1
Next j
Next i
Dim As Integer n5 = 500, cont = 0
Print "First 50 numbers which are the cube roots"
Print "of the products of their proper divisors:"
For i = 1 To Ubound(pdc)
If pdc(i) = 7 Then
cont += 1
If cont <= 50 Then
Print Using "####"; i;
If cont Mod 10 = 0 Then Print
Elseif cont = n5 Then
Print Using !"\n#########th: &"; cont; i;
n5 *= 10
End If
End If
Next i
Sleep
You may also check:How to resolve the algorithm Pythagorean quadruples step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Soundex step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Entropy/Narcissist step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Empty string step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Ascending primes step by step in the FreeBASIC programming language