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

Home > Numbers
Squares built from leftovers (Posted on 2018-04-05) Difficulty: 2 of 5
Let N1=123456789
Erase n digits and shrink the remnants of N1 into one continuous chain creating a new number N1'.

What is the minimum number of digits to be erased so that N1' will be a square number?

Same question for N2=987654321 and N2'.

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 4
N1
leftover  square root
     9        3
     4        2
    49        7
    36        6
   289       17
    25        5
   256       16
     1        1
    16        4
   169       13
  1369       37
 13689      117
134689      367  minimum number of digits erased: 3
 13456      116
 
N2
leftover  square root
     1        1
     4        2
    64        8
    81        9
   841       29  minimum number of digits erased: 6  
     9        3
   961       31  minimum number of digits erased: 6
   
DefDbl A-Z
Dim crlf$, nx$, leftovers$


Private Sub Form_Load()
 Form1.Visible = True
 Text1.Text = ""
 crlf = Chr(13) & Chr(10)
 
 nx$ = "123456789"
 leftovers = ""
 
 buildon 1
 
 
 nx$ = "987654321"
 leftovers = ""
 
 buildon 1
 
 
 Text1.Text = Text1.Text & crlf & ct & " done"
  
End Sub

Sub buildon(wh)
  For i = 0 To 1
   DoEvents
   sve$ = leftovers
   If i Then leftovers = leftovers + Mid(nx, wh, 1)
   If wh = 9 Then
     sq = Val(leftovers)
     sr = Int(Sqr(sq) + 0.5)
     If sr * sr = sq Then
       Text1.Text = Text1.Text & mform(sq, "#####0") & "   " & mform(sr, "#####0") & crlf
     End If
   Else
     buildon (wh + 1)
   End If
   leftovers = sve
  Next
End Sub

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function
   

  Posted by Charlie on 2018-04-05 12:27:33
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 (15)
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