+ 1

Problem with lesson 23

I've done a task but the result at the end still not noticed that I've done it right. All tests passed right. Result shows wrong answer for a task and offers me to try it again. I don't know what should I do in this case. Pls help.

19th Feb 2021, 12:04 PM
Oleg Zakhoda
Oleg Zakhoda - avatar
5 Answers
+ 1
What is the purpose of 2nd if condition? You are adding extra * by 2nd if condition..
19th Feb 2021, 1:09 PM
Jayakrishna 🇼🇳
+ 1
int number = Convert.ToInt32(Console.ReadLine()); int r = 1; do { if (r%3==0){ Console.Write ("*"); }else { Console.Write (r); } if (number%3==0){ Console.Write ("*"); } r++; } while (r <= number);
19th Feb 2021, 12:04 PM
Oleg Zakhoda
Oleg Zakhoda - avatar
+ 1
The second "if" condition is needed if the entered number is also divisible by 3. In the terms of the task it was said about it. So, thanks, without second "if" it works :)
19th Feb 2021, 2:01 PM
Oleg Zakhoda
Oleg Zakhoda - avatar
+ 1
Seems logical. I agree, I didn't think about it. You're right :)
20th Feb 2021, 4:31 AM
Oleg Zakhoda
Oleg Zakhoda - avatar
0
you are using condition r<=number so it covers for entered number also... so no need 2nd if. You're welcome..
19th Feb 2021, 2:09 PM
Jayakrishna 🇼🇳