World's most popular travel blog for travel bloggers.

[Solved]: Recursive definition of sum of two numbers in terms of the successor function

, , No Comments
Problem Detail: 

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 as

succ(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?

Asked By : Aseem Bansal

Answered By : Yuval Filmus

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.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/13659

0 comments:

Post a Comment

Let us know your responses and feedback