Sudan function: Difference between revisions
Content added Content deleted
(Added C++ implementation) |
(Added C# implementation) |
||
Line 74: | Line 74: | ||
cout << "F(1,3,3) = "<<F(1,3,3)<<endl; |
cout << "F(1,3,3) = "<<F(1,3,3)<<endl; |
||
return 0; |
return 0; |
||
} |
|||
</lang> |
|||
Output |
|||
<pre> |
|||
F(1,3,3) = 35 |
|||
</pre> |
|||
=={{header|C Sharp|C#}}== |
|||
{{trans|C}} |
|||
<lang csharp> |
|||
//Aamrun, 11th July 2022 |
|||
using System; |
|||
namespace Sudan |
|||
{ |
|||
class Sudan |
|||
{ |
|||
static 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); |
|||
} |
|||
static void Main(string[] args) |
|||
{ |
|||
Console.WriteLine("F(1,3,3) = " + F(1,3,3)); |
|||
} |
|||
} |
|||
} |
} |
||
</lang> |
</lang> |