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

Home > Numbers
Double the Digits (Posted on 2023-09-28) Difficulty: 3 of 5
The binary integer 110101 has 2 zeroes and 4 ones. Its square 101011111001 has double that, namely 4 zeroes and 8 ones.

Similarly, the ternary integer 20211 has 1 zero, 2 ones and 2 twos. Its square 1201102221 has double that, namely 2 zeroes, 4 ones and 4 twos.

Find the first 3 decimal (base ten) integers with this property.

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 computer solution | Comment 1 of 2
Trying up to 5-digit base numbers found only one such case. Going to 6-digit numbers brought the total to six such pairs of numbers.

clearvars,clc
for n=1:999999
  ns=char(string(n));
  n2s=char(string(n^2));
  nct=[];
  for i=0:9
    ct=length(strfind(ns,char(string(i))));
    nct=[nct ct];
  end
  n2ct=[];
  for i=0:9
    ct=length(strfind(n2s,char(string(i))));
    n2ct=[n2ct ct];
  end
  if n2ct==2*nct
    disp([n n^2]);
  end
end

finds

      n          n^2
    72576     5267275776
   406512   165252006144
   415278   172455817284
   494462   244492669444
   603297   363967270209
   725760   526727577600

  Posted by Charlie on 2023-09-28 08:47:43
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 (8)
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