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

Home > Numbers
Integers with Happy, Healthy Babies (Posted on 2023-01-26) Difficulty: 3 of 5
An integer has a baby if its square root appears inside it.
To be inside, there must be at least one parental digit on either side of the baby.
A baby is happy if it is perfectly centered within its parent integer, ie the same number of digits to its left and to its right.
A baby is healthy if the baby does not contain any zeros.

For example, the square root of 62500 is 250, so 62500 has a happy, but unhealthy baby.
The square root of 214651801 is 14651, so 214651801 has a healthy but unhappy baby. This baby has one digit to its left, but three digits to its right.

Find the first 4 integers with happy, healthy babies.

No Solution Yet Submitted by Larry    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 1 of 1
clearvars,clc

for n=uint64(1):uint64(90000000)
   ns=string(n);sqs=string(n^2);
   charn=char(ns);
   charsq=char(sqs);
   ix=strfind(sqs,ns);
   diff=length(charsq)-length(charn);
   if mod(diff,2)==0
     for j=1:length(ix)
       if  ix(j)==diff/2+1
         if length(strfind(ns,'0'))==0
           fprintf('%10d %20d\n',n, n^2)
         end
       end
     end
   end
end

finds

     Baby
   (square         Integer with
     root)          H, H. Baby  
      3792             14379264
    495475         245495475625
    971582         943971582724
  66952741     4482669527413081


  Posted by Charlie on 2023-01-26 10:32:05
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 (0)
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