OFFSET
1,1
COMMENTS
LINKS
Francesco Di Matteo, Table of n, a(n) for n = 1..300
Francesco Di Matteo, Calculating the A270270 terms
EXAMPLE
PROG
(Python)
# init values
seq = [4] # the output list
somme = [4] # the n-value list after the adding of the last seq term
last = [10] # last a(n) term, or the first k-digit number (10 with k=2)
# CLIMBING loop, put a bigger value if you want
for n in range (1, 30):
k = (len(somme)+1) # the digits number
limit = 10**k # the newest value to achieve
base = (somme[-1]+1)*k # this is the (n+1)*k value
hypo = seq[-1]*3 # to obtain rapidly the limite value
rid = 10**(len(str(hypo))-1) # the reduction factor
# Adjustment LOOP #
s, p, m = 0, 0, 0
while s < 1:
diff_1 = (base + (base + (k*(hypo-1))))*float(hypo)/2
tot = last[-1] + diff_1
if tot < limit:
p = 1
if m == 1 and rid > 1:
m = 0; rid = rid/10
hypo = hypo + rid
else:
diff_2 = (base + (base + (k*(hypo-2))))*float(hypo-1)/2
tot = last[-1] + diff_2
if tot > limit:
m = 1
if p == 1 and rid > 1:
p = 0; rid = rid/10
hypo = hypo - rid
else:
s = 1 # escape value
# lists updating
seq.append(hypo)
somme.append(somme[-1]+ hypo)
last.append(last[-1]+ diff_1)
# if you want to prove the conjecture values, uncomment next line
#print(seq[-1], float(seq[-1])/seq[-2])
print(seq)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Francesco Di Matteo, Mar 14 2016
STATUS
approved