Skip to content

Instantly share code, notes, and snippets.



Last active Feb 8, 2019
What would you like to do?
A simple, but mysterious function
// This is simply some pseudo code; applicable to any programming language that has support for
// basic data types and recursive functions
// Two questions:
// 1- Solve the "mystery": what does the function do?
// 2- Enhance the function to accommodate other integers.
function mystery(int a, int b) {
if (b == 1) {
return a
return mystery(a, b - 1) + a

This comment has been minimized.

Copy link

@vapporwashmade vapporwashmade commented Feb 8, 2019

It is a function that shows multiplication by repeated addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment