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

Home > Numbers
List the expressionist numbers (Posted on 2016-05-30) Difficulty: 4 of 5
Consider numbers like 343 or 2592.
343=(3+4)^3
2592=2^5*9^2.

We have just shown that some numbers stay unchanged when a number of mathematical operators are added /inserted, without changing the order of the digits.
Within our puzzle lets call those numbers expressionist numbers.
Let us limit the set of acceptable mathematical symbols to the following operators: +, -, *, /, ^, sqrt, !. and any amount of brackets.

My questions:
In the period between 10 A.D. & 2016 A.D. what years were labeled by expressionist numbers?
How many such years will there be between 2017 A.D. & 9999 A.D.?

Bonus: How about one, two (or more) 5-digit examples?

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer "solution" part 1 -- no guarantee of completeness | Comment 3 of 10 |
Part 1:

Here are RPN versions (translated to algebraic further down below).  Square root (postfix r) was limited to twice in a row (so as to allow 4th roots but not 8th roots). For the first batch, depth was limited to 20 characters. Later on, for speed, this was reduced to 16. Other than that, only the 15-decimal-digit accuracy of the programming language limited the possibilities. Only the first found solution is given for each value, even if it wouldn't be the simplest.

All that being the case, it may be that others should be on the list, such as any that require more than two square roots applied successively or have intermediate results that exceed the precision of the programming language. While the final result was allowed to be slightly off to allow for rounding error, such was not applied to intermediate results, so if the 4th power of a fourth root, for example, was slightly off, the result was not allowed to be used to take a factorial, though in fact such rounding would probably be legitimate.

24  24r+!
36  3!6*
71  7!1+r
120  12+!0!-!
144  14r+!4!*
145  14!+5!+
216  21+!r6^
240  24!0!+r!*
324  3!2r/4^
343  34+r3!^
354  35!4r-*
355  35!*5-
360  360!-!*
384  3!rr8r*4^
456  45!6-*
693  6!9rr3!^-
715  71-!5-
720  72r0*!-!
721  72+r!!1+
722  72+r!!2+
723  72+r!!3+
724  72+r!!4+
725  72+r!!5+
726  72+r!!6+
727  72+r!!7+
728  72+r!!8+
729  72+r!!9+
733  73!!+3!+
736  736^+
744  74r+r!!4!+
936  9r!r3!^6!+
1285  128^+5*
1288  12+!r8^8-
1296  12+!r9r!^6*
1298  12*9r!r8^+
1434  14r+!!3-4r*
1435  14r+!!3!!+5-
1439  14r-3!!+9r!!+
1440  14r+!!4r*
1441  14r+!!4r*1+
1442  14r+!!4r*2+
1443  14r+!!4r*3+
1444  14r+!!4r+4r*
1445  14r+!!4r*5+
1446  14r+!!4r*6+
1447  14r+!!4r*7+
1448  14r+!!4r*8+
1449  14r+r4!^r9r!!+
1464  14r+!!6!+4!+
1573  15!+73!+*
1679  167!-9r/-
1680  16+!80!+r/
1704  17!+r0!*4!*
1764  17r*6r*4^
1944  19r!rr*4!^4!/

 done
 
from

DefDbl A-Z
Dim crlf$, stack(20), expr$, done, stackSave(20), yr, stackLevel, fact(15), yrLen, ys$


Private Sub Form_Load()
 Form1.Visible = True
 
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 fact(0) = 1
 For i = 1 To 15
   fact(i) = fact(i - 1) * i
 Next
 
 For yr = 10 To 2016
  ' Text1.Text = Text1.Text & Str(yr)
   ys$ = LTrim(Str(yr)): yrLen = Len(ys)
   expr$ = Left(ys, 1)
   done = 0
   stack(1) = Val(expr)
   stackLevel = 1
   addOn 2
 Next
  
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Sub addOn(wh)
 If done Then Exit Sub
 If Len(expr) > 20 Then Exit Sub
 DoEvents
 ' done = 0
  For mono = 1 To 2
   expSave$ = expr
   stack1save = stack(1)
   Select Case mono
    Case 1 ' square root
      If Right(expr, 2) <> "rr" And stack(1) >= 2 Then
        stack(1) = Sqr(stack(1)): expr = expr + "r"
        If Abs(stack(1) - yr) < 0.00000001 And stackLevel = 1 And wh >= yrLen Then
             Text1.Text = Text1.Text & yr & "  " & expr & crlf
             done = 1
        End If
        If done = 0 Then addOn wh
      End If
    Case 2 ' factorial
      If stack(1) = Int(stack(1)) And stack(1) >= 0 And stack(1) < 16 And stack(1) <> 1 And stack(1) <> 2 Then
        stack(1) = fact(stack(1)): expr = expr + "!"
        If Abs(stack(1) - yr) < 0.00000001 And stackLevel = 1 And wh >= yrLen Then
             Text1.Text = Text1.Text & yr & "  " & expr & crlf
             done = 1
        End If
        If done = 0 Then addOn wh
     End If
   End Select
   expr = expSave
   stack(1) = stack1save
  Next
 If expr = "34+3!+" Then
   x = x
 End If
  
  If stackLevel > 1 Then
    expSave = expr
    For op = 1 To 5
      stack1save = stack(1)
      stack2save = stack(2)
      good = 1
      Select Case op
        Case 1 ' add
          stack(1) = stack(2) + stack(1)
          expr = expr + "+"
        Case 2 ' subtract
          stack(1) = stack(2) - stack(1)
          expr = expr + "-"
        Case 3 ' multiply
          stack(1) = stack(2) * stack(1)
          expr = expr + "*"
        Case 4 ' divide
          If stack(1) <> 0 And Abs(stack(1)) < 1E+100 And Abs(stack(1)) > 1E-200 Then
            stack(1) = stack(2) / stack(1)
            expr = expr + "/"
          Else
            good = 0
          End If
        Case 5 ' exponentiate
            If stack(2) = 0 Then
              If stack(1) = 0 Then
                good = 0
              Else
                stack(1) = 0
              End If
            ElseIf stack(1) = 0 Or stack(2) = 1 Then
              stack(1) = 1
            ElseIf stack(2) < 0 Then
              If stack(1) = Int(stack(1)) And Abs(stack(1) * Log(Abs(stack(2)))) < 35 Then
                 stack(1) = Abs(stack(2)) ^ stack(1)
                 q = Int(stack1save / 2)
                 r = stack1save - 2 * q
                 If r = 1 Then stack(1) = -stack(1)
              Else
                 good = 0
              End If
            Else
              If stack(1) < 1E+100 Then
               If stack(1) * Log(Abs(stack(2))) < 35 Then
                 stack(1) = stack(2) ^ stack(1)
               Else
                 good = 0
               End If
              Else
               good = 0
              End If
            End If

          If good Then expr = expr + "^"
      End Select
      If good Then
        For i = 2 To stackLevel - 1
          stack(i) = stack(i + 1)
        Next
        stackLevel = stackLevel - 1
        
        If expr = "25^92^*" Then
          x = x
        End If
        
        If Abs(stack(1) - yr) < 0.00000001 And stackLevel = 1 And wh >= yrLen Then
             Text1.Text = Text1.Text & yr & "  " & expr & crlf
             done = 1
        Else
            addOn wh
        End If
      
        
        liftStack
        stackLevel = stackLevel + 1
        stack(2) = stack2save
        stack(1) = stack1save
        expr = expSave
      End If
    Next op
    
  End If
  
  
  If wh <= yrLen Then
    liftStack
    stackLevel = stackLevel + 1
    saveExpr$ = expr
    
    stack(1) = Val(Mid(ys, wh, 1))
    expr = expr + Mid(ys, wh, 1)
    addOn (wh + 1)
    
    expr = saveExpr
    For i = 2 To stackLevel - 1
      stack(i) = stack(i + 1)
    Next
    stackLevel = stackLevel - 1
  End If
  
'  done = 0
  
  Exit Sub
  
  
End Sub

Sub liftStack()
  For i = stackLevel + 1 To 2 Step -1
    stack(i) = stack(i - 1)
  Next
End Sub

Remember that no concatenation is used here. Adjacent digits are separate numbers in the RPN in the second column. Lower case r postfixed represents square root. Two !!'s in a row do not represent double factorial but rather iterated factorial, e.g., 3!! = 6! = 720:

       RPN                    Algebraic
24    24r+!                 (2+sqrt(4))!
36    3!6*                  3! * 6
71    7!1+r                 sqrt(7! + 1)
120   12+!0!-!             ((1+2)! - 0!)!
144   14r+!4!*             (1+sqr(4))! * 4!
145   14!+5!+              1+4!+5!
216   21+!r6^              sqrt((2+1)!)^6
240   24!0!+r!*            2*(sqrt(4!+0!))!
324   3!2r/4^              (3! / sqrt(2))^4
343   34+r3!^              sqrt(3+4)^(3!)  (ok, it's a weird way)
354   35!4r-*              3*(5!-sqrt(4))
355   35!*5-               3*5!-5
360   360!-!*              3*(6-0!)!
384   3!rr8r*4^            (sqr(sqr(3!)*sqrt(8))^4
456   45!6-*               4*(5!-6)
693   6!9rr3!^-            6!-sqrt(sqrt(9))^(3!)
715   71-!5-               (7-1)!-5
720   72r0*!-!             (7-(sqrt(2)*0)!)!  
(sqrt above was completely unnecessary but it was the first found soln)
721   72+r!!1+             (sqrt(7+2))!!+1
722   72+r!!2+             (sqrt(7+2))!!+2
723   72+r!!3+             (sqrt(7+2))!!+3
724   72+r!!4+             (sqrt(7+2))!!+4
725   72+r!!5+             (sqrt(7+2))!!+5
726   72+r!!6+             (sqrt(7+2))!!+6
727   72+r!!7+             (sqrt(7+2))!!+7
728   72+r!!8+             (sqrt(7+2))!!+8
729   72+r!!9+             (sqrt(7+2))!!+9
733   73!!+3!+             7+3!!+3!
736   736^+                7+3^6
744   74r+r!!4!+           sqrt(7+sqrt(4))!!+4!
936   9r!r3!^6!+           sqrt((sqrt(9))!)^(3!) + 6!
1285  128^+5*             (1+2^8)*5             
1288  12+!r8^8-           sqrt((1+2)!)^8 - 8
The above were converted to algebraic manually but
from here on, program RPN2ALGB converted to algebraic
1296  12+!r9r!^6*         sqrt((1+2)!)^sqrt(9)!*6                               
1298  12*9r!r8^+          1*2+sqrt(sqrt(9)!)^8
1434  14r+!!3-4r*         ((1+sqrt(4))!!-3)*sqrt(4)
1435  14r+!!3!!+5-        (1+sqrt(4))!!+3!!-5
1439  14r-3!!+9r!!+       1-sqrt(4)+3!!+sqrt(9)!!
1440  14r+!!4r*           (1+sqrt(4))!!*sqrt(4)
                     For some reason, here in 1440 and some instances below,
                     the addition of zero at the end was left out (as in 0+ for RPN or +0 algebraic)
1441  14r+!!4r*1+         (1+sqrt(4))!!*sqrt(4)+1
1442  14r+!!4r*2+         (1+sqrt(4))!!*sqrt(4)+2
1443  14r+!!4r*3+         (1+sqrt(4))!!*sqrt(4)+3
1444  14r+!!4r+4r*        ((1+sqrt(4))!!+sqrt(4))*sqrt(4)
1445  14r+!!4r*5+         (1+sqrt(4))!!*sqrt(4)+5
1446  14r+!!4r*6+         (1+sqrt(4))!!*sqrt(4)+6
1447  14r+!!4r*7+         (1+sqrt(4))!!*sqrt(4)+7
1448  14r+!!4r*8+         (1+sqrt(4))!!*sqrt(4)+8
1449  14r+r4!^r9r!!+      sqrt(sqrt((1+sqrt(4)))^4!)+sqrt(9)!!
1464  14r+!!6!+4!+        (1+sqrt(4))!!+6!+4!
1573  15!+73!+*           (1+5!)*(7+3!)
1679  167!-9r/-           1-(6-7!)/sqrt(9)
1680  16+!80!+r/          (1+6)!/sqrt((8+0!))
1704  17!+r0!*4!*         sqrt((1+7!))*0!*4!
1764  17r*6r*4^           (1*sqrt(7)*sqrt(6))^4
1944  19r!rr*4!^4!/       (1*sqrt(sqrt(sqrt(9)!)))^4!/4!

Remember that all infix operatiors take precedence over diadic operators, such as factorial over exponentiation: x^4! is x^(4!).


  Posted by Charlie on 2016-05-31 07:27:45
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (17)
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