Advertisement
Lirbo

College - Data Structures Stack sum recursion

Nov 24th, 2022
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.18 KB | None | 0 0
  1. public static int rSum(Stack<int>s, int val)
  2.         {
  3.             if (s.IsEmpty())
  4.                 return val;
  5.             else
  6.                 return rSum(s, s.Pop()+val);
  7.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement