+ 3
Need explanation to challenge questions.
https://imgur.com/a/6gaUkNn Q1 https://imgur.com/a/yr1ExL0 Q2 https://imgur.com/a/4wNvLHq Q3 https://imgur.com/a/vQKIxVl Q4 Really need help understanding these challenge questions. I can usually figure out where I go wrong but I'm at a complete loss. I also really suck at for loops.
1 ответ
+ 2
1 - Because the only two possible numbers you get from mod 2 (%2) is either 0 or 1, thus the count is 2.
2 - For this one, its a bit long, but it is basically recursion. For the first iteration:
a = "at"
b = "" // Because 0 to 0 is actually an empty string
Then recusive call:
a = "t"
b = ""
Then second recursive call:
// since "t".Length is <= 1 Console.Write(s) outputs t
And so on.
3 - x variable is being ++'d 2 times per iteration, and y only once. Thus y = 5
4 - The first number that meets the condition of mod 2 and mod 4 being equal, is 4. Since 2 and 3 do not meet this, they get appended to y. Thus 23.