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

Home > Numbers
Defining a number (Posted on 2019-01-05) Difficulty: 3 of 5
My number consists of 3 digits in strictly increasing order. It is a semiprime number, both factors terminating by the same digit.
Find it.

Bonus: is there a solution for 4-digit number?

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solutions Comment 2 of 2 |
I didn't include perfect squares, but I still had 10 solutions for the 3-digit case as did xdog: I have 489 and 579 instead of his two squares.  The numbers are followed by their two factors each.

129 3 43
159 3 53
249 3 83
259 7 37
469 7 67
489 3 163
579 3 193
679 7 97
689 13 53
789 3 263

Perhaps 689 best fills the spirit of the question as each factor has more than one digit, so they can terminate in the same digit, rather than one being the terminating digit of the other.

In the 4-digit case:

1379 7 197
1389 3 463
1469 13 113
1569 3 523
1589 7 227
1679 23 73
1689 3 563
2359 7 337
2369 23 103
2469 3 823
2479 37 67
2569 7 367
2589 3 863
3459 3 1153
3489 3 1163
3569 43 83
3579 3 1193
3589 37 97
3679 13 283
4569 3 1523
4589 13 353
5789 7 827

Again this does not include any perfect squares that may satisfy the condition trivially (as far as matching terminal digits).

DefDbl A-Z
Dim crlf$, fct(20, 1)


Private Sub Form_Load()
 Form1.Visible = True
 
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 For n = 111 To 10000
   f = factor(n)
   If f = 2 Then
     If fct(1, 1) = 1 And fct(2, 1) = 1 Then
      If fct(1, 0) Mod 10 = fct(2, 0) Mod 10 Then
       ns$ = LTrim(Str(n))
       good = 1
       For i = 1 To Len(ns) - 1
         If Mid(ns, i + 1, 1) <= Mid(ns, i, 1) Then good = 0: Exit For
       Next
       If good Then Text1.Text = Text1.Text & n & Str(fct(1, 0)) & Str(fct(2, 0)) & crlf
      End If
     End If
   End If
   DoEvents
 Next
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Function factor(num)
 diffCt = 0: good = 1
 n = Abs(num): If n > 0 Then limit = Sqr(n) Else limit = 0
 If limit <> Int(limit) Then limit = Int(limit + 1)
 dv = 2: GoSub DivideIt
 dv = 3: GoSub DivideIt
 dv = 5: GoSub DivideIt
 dv = 7
 Do Until dv > limit
   GoSub DivideIt: dv = dv + 4 '11
   GoSub DivideIt: dv = dv + 2 '13
   GoSub DivideIt: dv = dv + 4 '17
   GoSub DivideIt: dv = dv + 2 '19
   GoSub DivideIt: dv = dv + 4 '23
   GoSub DivideIt: dv = dv + 6 '29
   GoSub DivideIt: dv = dv + 2 '31
   GoSub DivideIt: dv = dv + 6 '37
   If INKEY$ = Chr$(27) Then s$ = Chr$(27): Exit Function
 Loop
 If n > 1 Then diffCt = diffCt + 1: fct(diffCt, 0) = n: fct(diffCt, 1) = 1
 factor = diffCt
 Exit Function

DivideIt:
 cnt = 0
 Do
  q = Int(n / dv)
  If q * dv = n And n > 0 Then
    n = q: cnt = cnt + 1: If n > 0 Then limit = Sqr(n) Else limit = 0
    If limit <> Int(limit) Then limit = Int(limit + 1)
   Else
    Exit Do
  End If
 Loop
 If cnt > 0 Then
   diffCt = diffCt + 1
   fct(diffCt, 0) = dv
   fct(diffCt, 1) = cnt
 End If
 Return
End Function


  Posted by Charlie on 2019-01-05 13:47:53
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 (12)
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