How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the FreeBASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the FreeBASIC programming language
Table of Contents
Problem Statement
Calculate the sequence where each term an is the smallest natural number greater than the previous term, that has exactly n divisors.
Show here, on this page, at least the first 15 terms of the sequence.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the FreeBASIC programming language
Source code in the freebasic programming language
#define UPTO 15
function divisors(byval n as ulongint) as uinteger
'find the number of divisors of an integer
dim as integer r = 2, i
for i = 2 to n\2
if n mod i = 0 then r += 1
next i
return r
end function
dim as ulongint i = 2
dim as integer n, nfound = 1
print 1;" "; 'special case
while nfound < UPTO
n = divisors(i)
if n = nfound + 1 then
nfound += 1
print i;" ";
end if
i+=1
wend
print
end
You may also check:How to resolve the algorithm String append step by step in the Arturo programming language
You may also check:How to resolve the algorithm Empty program step by step in the ERRE programming language
You may also check:How to resolve the algorithm Hough transform step by step in the Wren programming language
You may also check:How to resolve the algorithm Brazilian numbers step by step in the Go programming language
You may also check:How to resolve the algorithm Guess the number step by step in the Sidef programming language