0

Multiply of 3 case issues

I've been puzzling for a while on this problem. I have got the first 3 test cases right but the 4th and 5th case wrong. I can't view those cases so I am unsure what the issue is or what I am overlooking. Help is much appreciated. Here's my code using System; using System.Collections.Generic; namespace SoloLearn { class Program { static void Main(string[] args) { int number = Convert.ToInt32(Console.ReadLine()); int x; //your code goes here for(x=1;x<=number;x++) { if(x%3==0) { Console.Write("*"); x++; } else if(number==0) { break; } Console.Write(x); } } } }

21st Jun 2021, 6:27 PM
Jarryd
4 Respuestas
+ 2
you can do it like this int number = Convert.ToInt32(Console.ReadLine()); for(int i = 1; i <= number; i ++){ if(i % 3 == 0){ Console.Write("*"); continue; } Console.Write(i); }
21st Jun 2021, 6:36 PM
JRAMAHES
JRAMAHES - avatar
0
Thanks, it passed all 5 test cases now. Much appreciated
21st Jun 2021, 6:43 PM
Jarryd
0
your wel
21st Jun 2021, 6:48 PM
JRAMAHES
JRAMAHES - avatar
- 1
discard x++ and apply continue because the problem is asking for multiply by 3 hope this help ?
21st Jun 2021, 6:38 PM
JRAMAHES
JRAMAHES - avatar