Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Kaprekar-numbers/FutureBasic/kaprekar-numbers.basic
Normal file
28
Task/Kaprekar-numbers/FutureBasic/kaprekar-numbers.basic
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
local fn kaprekar( n as NSInteger ) as BOOL
|
||||
NSInteger s = n^2
|
||||
double t = 10^(int(log(s)) + 1)
|
||||
BOOL result = NO
|
||||
|
||||
do
|
||||
t = t / 10
|
||||
if t <= n then break
|
||||
if s - n == int(s/t)*(t-1) then result = YES : exit fn
|
||||
until ( t <= n )
|
||||
result = ( n = YES )
|
||||
end fn = result
|
||||
|
||||
local fn DoIt
|
||||
NSInteger i
|
||||
float n = 0
|
||||
for i = 1 to 1000000
|
||||
if ( fn kaprekar(i) )
|
||||
n++
|
||||
if i < 1000000 then printf @"%2.f : %ld", n, i
|
||||
end if
|
||||
next
|
||||
print "Kaprekar numbers under 1,000,000 = "; n
|
||||
end fn
|
||||
|
||||
fn DoIt
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue