How to resolve the algorithm Disarium numbers step by step in the FutureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Disarium numbers step by step in the FutureBasic programming language
Table of Contents
Problem Statement
A Disarium number is an integer where the sum of each digit raised to the power of its position in the number, is equal to the number.
135 is a Disarium number: 11 + 32 + 53 == 1 + 9 + 125 == 135 There are a finite number of Disarium numbers.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Disarium numbers step by step in the FutureBasic programming language
Source code in the futurebasic programming language
long c = 0, n = 0, t, i
CFStringRef s
while ( c < 18 )
s = fn StringWithFormat(@"%ld",n)
t = 0
for i = 0 to len(s) - 1
t += intVal(mid(s,i,1))^(i+1)
next
if ( t == n )
print n
c++
end if
n++
wend
HandleEvents
You may also check:How to resolve the algorithm Sum and product of an array step by step in the Bracmat programming language
You may also check:How to resolve the algorithm Haversine formula step by step in the R programming language
You may also check:How to resolve the algorithm Arithmetic/Integer step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm K-means++ clustering step by step in the Huginn programming language
You may also check:How to resolve the algorithm Web scraping step by step in the Seed7 programming language