Recursive definition of sum of two numbers in terms of the successor function
-
16-10-2019 - |
Question
This is a question from the book Data structures using C and C++ by Tenenbaum
. Not a homework problem but self-study.
Recursive definition of a+b, where a and b are non-negative integers, in terms of successor function
succ
defined assucc(int x) { return(x++); }
I have been thinking how is it possible? Can I change the function? I am not sure from the problem definition in the book. So how can this be done?
Solution
Here is a hint:
a + 3 = succ(succ(succ(a)))
Also, by definition, every natural number is either 0 or the successor of some (smaller) natural number.
Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange