5 ms·
> use any mathematical operations Okay, then this is easy, just use the successor function. S(n) = n+1 6 = 2*2*2-2 7 = S(2*2*2-2) 8 = S(S(2*2*2-2))
by tantalor 2y ago
> use any mathematical operations
Okay, then this is easy, just use the successor function.
S(n) = n+1
6 = 2*2*2-2
7 = S(2*2*2-2)
8 = S(S(2*2*2-2))
Etc.
- miningape 2y agolambda calculus has entered the chat
- Buttons840 2y agohttps://wiki.haskell.org/Peano_numbers https://wiki.haskell.org/Peano_numbers
- Hamuko 2y agoI feel like having a 1 on the first line is cheating given the constraint "using no other digits".
- tessierashpool9 2y agolog is also using another digit.
- tantalor 2y agoBy that argment you shouldn't be able to use factorial function either, because that has a "hidden 1" too: fac(n) = n * fac(n-1) n>0 = 1 n=0
- Hamuko 2y agoThe one here isn't hidden in any way – it's on the very first line. You might as well just define X = 7 and do 2-2+2-2+X.
- tantalor 2y agoI'm not "defining" anything; I'm just using fairly bog standard math that has been around for hundreds of years.
- empath75 2y agoS(N) is just S(N), it's not N+1 unless you define it that way. S(0) is not 1, it's S(0). The successor function doesn't really get mapped to numbers without an explicit additional mapping.
- account42 2y agoUnless you are talking about an alternative number system where 1+1 is not 2 then yes, S(0) is 1.
- empath75 2y agoNo, it's not. That's just the standard model of peano arithmetic. You can map the successor function to many different operations and objects that aren't even numbers.
- account42 2y agoYes it is. "1" is just a label for what is also known as S(0) no mater what other ways you invent to refer to that element. Just like 一 is another label for the same concept.
- Aardwolf 2y agoFinding the shortest expression with 4 2's for a given integer would be a more interesting challenge
- 0xfffafaCrash 2y agoI had the same thought. Also with square roots hiding 2s behind notation, etc. The whole project isn’t really very coherent without specifying what specific operators you can use (and how many times).
- venusenvy47 2y agoI took a lot of math in my schooling, and have continued using math on a daily basis in my engineering career. I even subscribe to many math channels on YouTube, but this is the first time in my life that I've even heard of this function. I know there aren't real rules to this puzzle, but this function doesn't seem well-known at all.
- tantalor 2y agoIt has a rich history going back to the formalization of arithmetic in the 1800s. https://en.wikipedia.org/wiki/Peano_axioms https://en.wikipedia.org/wiki/Peano_axioms It's probably something that only folks who study the foundations of mathematics would know. You may have also heard about it if you learned about Gödel's incompleteness theorems, or read Gödel, Escher, Bach
- empath75 2y agoThe successor function is how natural numbers are defined in most axiomatic arithmetic systems. A natural number is either zero or a successor of a natural number. Addition is defined as a recursive application of successor functions. m + 0 = m, m + S(n) = S(m + n). as an example -- 3 + 2: S(S(S(0))) + S(S(0)) = S( S(S(S(0))) + S(0) ) = S( S( S(S(S(0))) + 0 ) ) = S(S(S(S(S(0))))) There's nothing really in the definition of the successor function that necessarily requires that it's interpreted as n+1, though. It's just an interpretation from the context in which it's used. It could represent any operation as long as it is isomorphic to adding one -- but there's nothing special about "adding one". You could have it represent multiplying by a constant, and interpret "zero" as the number one. So a number in this interpretation is either 1; or 2 times a natural number. 1, 2, 4, 8, 16, 32 -- you're working only with powers of 2 now. The above "addition" rule above still works, but now it represents "multiplication" instead of addition. I'll replace all the S's in the above example with x2 2x2x2x1 "+" 2x2x1 = 2x(2x2x2x1 + 2x1) = 2x(2x(2x2x2x1 + 1) = 2x2x2x2x2x1 = 32 So now, instead of addition, we've recursively defined multiplication where the successor function is interpreted as multiplying by 2. There's an infinite number of ways that you can interpret the successor function. So basically, I do think it's cheating, and if you do want to define it as n+1, it would be even simpler to just define a function that takes any number to the desired output.