you have a 4 sided piramid and a 3 sided one
they differ in size 1 kokonut
how big are the piramid's ?
error :
function sum() isn't right
? :
are there solutions above 400
how do i speed this up
Code: Select all
'' bluatigro 8 feb 2018
'' piramid's
function sum( a() as integer , l as integer )
dim as integer i , uit
for i = 0 to l
uit += a( i )
next i
return uit
end function
const as integer q = 400
dim as integer qa( q ) , qb( q ) , a( q ) , b( q ) , i , n , temp
for i = 0 to q
qa( i ) = 0
qb( i ) = 0
next i
for n = 1 to q
qa( n ) = n * n
a( n ) = sum( qa() , n )
temp = 0
for i = 1 to n
qb( i ) = i
temp = temp + sum( qb() , i )
next i
b( n ) = temp
next n
for i = 1 to q
for n = 1 to q
if abs( a( i ) - b( n ) ) <= 1 then
print i , a( i ) , n , b( n )
end if
next n
next i
sleep
end