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

Home > Numbers
Evened N and 3N Extended (Posted on 2023-07-29) Difficulty: 4 of 5
N is a number with the property that all its digits are even.
3N also has that property.
Example: N=208 and 3N=624.

How many possible values of N have 22 digits? (3N may have 22 or 23 digits.)

For reference: Evened N and 3N is a version of this problem where N is only a 3 digit number.

See The Solution Submitted by Brian Smith    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts Probably solution, with a little help | Comment 1 of 4
Working this out for number of digits 0 to 6 gives:
1, 2, 7, 24, 82, 280, 956

Some observations:
Any N between (1/3) and (2/3) of a power of 10 will result in 3N being one digit longer and starting with a 1.
In fact N can begin only with {2,6,8};
        N can only end with {0,2,8}
        digits other than the first and last are restricted to {0,2,6,8}
        a 6 can be followed only by {6,8}
I suspect these digit restrictions may be enough to find a solution but I have not tested it yet for numbers longer than about 6-digits.

And then there is Sloane's OEIS.  Indeed the sequence shows up with two different generating rules.  For readability assume somewhere mid sequence is:  ..., a, b, c, ....

A003480   c = 4b-2a
A020727   c = round(b^2/a)
(each valid only after the first few elements)
The ratio of a(n)/a(n-1) approaches 2+√2

The function seqP(n), see below, generates a list for i from 1 to n, using the formula c = round(b^2/a)

Following the pattern, thanks to oeis, the count for 22-digit numbers would appear to be:
    325919783936
I did make some code to directly find this for a given number of digits, but my code, in Python, on my laptop was too slow.
So I would conclude that 325919783936 is probably the answer, but not confirmed.


------------
def isAllEven(n):
    """ input an integer, if all digits are even then output True """
    odds = '13579'
    if n >= 10:
        return isAllEven(n//10) and isAllEven(n%10)
    if n < 10 and str(n) in odds:
        return False
    if  n < 10 and str(n) not in odds:
        return True

def seqP(n):
    ans = [1,2,7]
    for i in range(3,n+1):
        ans.append(round(ans[i-1]**2 / ans[i-2]))
    return ans
------------
# This code will give solution for a given number of digits, but gets slow for larger numbers
ns = []
count = 0
numDigits = 4
for i in range(10**(numDigits-1),10**(numDigits),2):
    if isAllEven(i):
        if isAllEven(3*i):
            count += 1
            # print(i,3*i)
            ns.append(i)
print(len(ns))
------------
#  This code will get solution for one more number of digits
sols = [[0],[2,8],[20, 22, 28, 68, 80, 82, 88],[200, 202, 208, 220, 222, 228, 268, 280, 282, 288, 668, 680, 682, 688, 800, 802, 808, 820, 822, 828, 868, 880, 882, 888]]
sizes = [len(i) for i in sols]
digits = '0268'
after6 = [6,8]
endings = [0,2,8]
# take prior number of digits, try all possibles adding a digit at beginning, any gap or end.
nextlist = []

leng = len(str(sols[-1][0])) + 1
for i in sols[-1]:
    s = str(i)
    for d in digits:
        for gap in range(leng):
            if gap==0 and d==0:
                continue
            t = s[:gap] + d + s[gap:]
            # print(s,d,gap, s[:gap] , d , s[gap:] , t)
            if t[0]=='0' or t[-1]=='6' or '60' in t or '62' in t or t in nextlist:
                continue
            nextlist.append(t)

sols.append([int(n) for n in sorted(nextlist)])
sizes = [len(i) for i in sols]
print(sizes)

  Posted by Larry on 2023-07-29 12:06:15
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (13)
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