All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers > Sequences
Consecutive (Posted on 2023-12-25) Difficulty: 3 of 5
Find a sequence of consecutive integers, a, a+1, a+2, ..., b such that b is a square and that:
[a+(a+1)+(a+2)+...+(b-1)]b and [(a-1)+a+(a+1)+(a+2)+...+(b-1)]b are both 10-digit numbers containing all of the digits 0 to 9.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution Comment 2 of 2 |
Find closed forms for expressions 1 and 2 in terms of a and b.
expression1 =  b*((b+a-1)*(b-a)/2)
expression2 =  b*((b+a-2)*(b-a+1)/2) = expression1 + (a-1)b

Since b is a square, find range of possible integer values for √b
First, a can be as small as 1 and as large as b-1.
Since both expressions must be 10 digits, this limits √b to 35 to 316

Result:  I found only one solution for √b from 35 ... 316 inclusive
a     b    √b  expression1    expression2 
78 1296 36 [1083659472, 1083759264]

The requested sequence is:
(a, ..., b) = (78,79,80, ... 1274,1275,1296)
---------------
def issquare(n):
    """ Input an integer, Returns True iff it is a perfect square. """
    if round(n**0.5)**2 == n:
        return True
    else:
        return False
    
def s(a,b):
    if a >= b:
        return 0
    x = b*int((b+a-1)*(b-a)/2)
    return [x, x + (a-1)*b]

from itertools import permutations
pans = []
for perm in permutations('0123456789'):
    if perm[0] == '0':
        continue
    pans.append(int(''.join(perm)))

for sqrtb in range(35, 317):
    print(sqrtb)
    b = sqrtb**2
    for a in range(1,b):
        ns = s(a,b)
        if len(str(ns[0])) != 10:
            continue
        if len(str(ns[1])) != 10:
            continue
        if ns[0] not in pans:
            continue
        if ns[1] not in pans:
            continue
        print(a,b,sqrtb,s(a,b))

  Posted by Larry on 2023-12-25 09:45:52
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information