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.)
Solution same answer as Larry's | Comment 2 of 4 |
for d=1:7
  st=str2double(['2' repmat('0',1,d-1)]);
  nd=str2double(repmat('8',1,d));
  ct=0;
  for n=st:2:nd
    n3 = n * 3;
    tst = [char(string(n)) char(string(n3))];
    good = true;
    for i = 1:length(tst)
      if ~contains('02468', tst(i))
        good = false;
        break
      end
    end
    if good
      ct = ct + 1;
      %     disp([ n   n3])
    end
  end
  disp([d ct])
end

finds

  number  possible values
of digits    of N
     1          2
     2          7
     3         24
     4         82
     5        280
     6        956
     7       3264
     
Looking up the second column of numbers in the OEIS results in A003480 and A020727.

The former is described as a(n) = 4*a(n-1) - 2*a(n-2) (n >= 3) with elements 0 through 2 being 1, 2, 7. The latter sequence has a comment "It appears that a(n) = 4*a(n-1) - 2*a(n-2) (holds at least up to n = 1000 but is not known to hold in general)". But we're concerned only as far as 22, so they agree up to where we need one of them. 

N(1)=2; N(2)=7;N(3)=24;
for i=4:25
  N(i)=4*N(i-1) - 2*N(i-2);
  fprintf('%3d %14d\n',i, N(i));
end

produces

  4             82
  5            280
  6            956
  7           3264
  8          11144
  9          38048
 10         129904
 11         443520
 12        1514272
 13        5170048
 14       17651648
 15       60266496
 16      205762688
 17      702517760
 18     2398545664
 19     8189147136
 20    27959497216
 21    95459694592
 22   325919783936
 23  1112759746560
 24  3799199418368
 25 12971278180352
 
So, for 22-digit numbers, N has 325,919,783,936 possible values.

  Posted by Charlie on 2023-07-29 12:13:01
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