public class Easy
{
public int recursion (int x)
{
if (x == 0) return 0;
else if ((x % 2) == 0) return 1 + recursion (x -1);
else return 2 + recursion (x-1);
}
}
What is returned by recursion(5)?
Correct answer when someone gets it: [spoiler]8[/spoiler]
English
-
[quote]public class Easy { public int recursion (int x) { if (x == 0) return 0; else if ((x % 2) == 0) return 1 + recursion (x -1); else return 2 + recursion (x-1); } } What is returned by recursion(5)? Correct answer when someone gets it: [spoiler]8[/spoiler][/quote] == is a boolean.
-
Edited by Tringus: 4/2/2016 7:29:59 PMyes and? The boolean statements return true if the two values equal each other. If int x equals 6, then (x == 6) would return true.
-
Oh yeah, now I see. C# has been a long time for me.
-
Hhhhmmmmm is 8579053256854790
-
-
-
-