Three Simple Math Problems

April 12, 2019

Here are three simple math problems. They are intended to be solved analytically, with number theory, without using a computer or a calculator. But I cheated. All three problems come from the YouTube channel Mind Your Decisions, where you will find lots of similar problems.

  1. Solve for x and y where both are integers: 615 + x2 = 2y
  2. Find a three-digit number abc = 100a + 10b + c with none of the digits 0 such that abc = a! + b! + c!
  3. Find a three-digit number pie = 100p + 10i + e with none of the digits 0 such that √pi + e = √ pie

Your task is to solve the three problems; you can write programs to solve them, if you wish, but it is fun to solve them by hand. When you are finished, you are welcome to or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Advertisement

Pages: 1 2

One Response to “Three Simple Math Problems”

  1. Globules said

    Here’s a Haskell solution. I decided that overkill was appropriate and used the Z3 SMT solver via the SBV library. Problem 3 turned out to the most difficult one, as the straightforward problem statement mixed integers and algebraic reals which current solvers have great difficulty with. Reorganizing the expression to use only integers fixed that issue. (Also, the factorial function had to be written in a particular way to prevent the solver from going off the rails…)

    {-# LANGUAGE ScopedTypeVariables #-}
    
    import Data.SBV
    
    prob1 = optimize Lexicographic $ do
      [x, y] <- sWord32s ["x", "y"]
      constrain $ 615 + x*x .== 2.^y
      minimize "min |x|" $ abs x
      minimize "min y" y
    
    prob2 = sat $ do
      [a, b, c] <- sWord32s ["a", "b", "c"]
      solve [ a .> 0 &&& a .< 10
            , b .> 0 &&& b .< 10
            , c .> 0 &&& c .< 10
            , 100*a + 10*b + c .== fact' a + fact' b + fact' c
            ]
      where fact' = fact 10
    
    fact :: SWord32 -> SWord32 -> SWord32
    fact top n = fact1 1 1
      where fact1 prev m = ite (m .== top ||| m .== n)
                               (m * prev)
                               (fact1 (m * prev) (m + 1))
    
    prob3 = sat $ do
      [p, i, e] <- sIntegers ["p", "i", "e"]
      let pie = 100*p + 10*i + e
          pi = 10*p + i
      solve [ p .> 0 &&& p .< 10
            , i .> 0 &&& i .< 10
            , e .> 0 &&& e .< 10
            -- sqrt (pi) + e .== sqrt (pie) =>
            , pi .== ((pie - pi - e^2) `sDiv` (2*e))^2
            ]
    
    *Main> prob1
    Optimal model:
      x       = 59 :: Word32
      y       = 12 :: Word32
      min |x| = 59 :: Word32
      min y   = 12 :: Word32
    *Main> prob2
    Satisfiable. Model:
      a = 1 :: Word32
      b = 4 :: Word32
      c = 5 :: Word32
    *Main> prob3
    Satisfiable. Model:
      p = 1 :: Integer
      i = 6 :: Integer
      e = 9 :: Integer
    *Main> 
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: