Sudan function: Difference between revisions
Content added Content deleted
(Added Java implementation) |
(Added C++ implementation) |
||
Line 51: | Line 51: | ||
</pre> |
</pre> |
||
=={{header|C++}}== |
|||
{{trans|C}} |
|||
<lang cpp> |
|||
//Aamrun , 11th July, 2022 |
|||
#include <iostream> |
|||
using namespace std; |
|||
int F(int n,int x,int y) { |
|||
if (n == 0) { |
|||
return x + y; |
|||
} |
|||
else if (y == 0) { |
|||
return x; |
|||
} |
|||
return F(n - 1, F(n, x, y - 1), F(n, x, y - 1) + y); |
|||
} |
|||
int main() { |
|||
cout << "F(1,3,3) = "<<F(1,3,3)<<endl; |
|||
return 0; |
|||
} |
|||
</lang> |
|||
Output |
|||
<pre> |
|||
F(1,3,3) = 35 |
|||
</pre> |
|||
=={{header|Hoon}}== |
=={{header|Hoon}}== |
||
<lang Hoon> |
<lang Hoon> |