+ 5
Multiples of 3
You are an elementary school teacher and explaining multiplication to students. You are going to use multiplication by 3 as your example. The program you are given takes N number as input. Write a program to output all numbers from 1 to N, replacing all numbers that are multiples of 3 by "*". Sample Input 7 Sample Output 12*45*7 I don't need the code I just don't under stand what its asking and what I am supposed to do. Also where did the 12 and 45 come from
8 Respostas
- 3
Never mind, I realized that it was counting the numbers 1, 2, skipped 3, counted 4, and then 5
+ 7
Well. you're correct!
they simply replaced 3 with *
you also gonna need Console.write(); to print the numbers on the same line.
+ 3
using System;
using System.Collections.Generic;
namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            int number = Convert.ToInt32(Console.ReadLine());
          for (int i=1;i<=number;i++)
          
           if (i%3==0)
           {Console.WriteLine("*"); } 
           else 
           { Console.WriteLine(i);}
        }
    }
}
+ 2
Don't give up Aleksei Gorlanov
+ 1
This code outputs exactly what is asked by the problem but is not passing all the tests. 
using System;
using System.Collections.Generic;
namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            // transform to integer
            int number = Convert.ToInt32(Console.ReadLine());
            
            //your code goes here
            for(int i = 1; i < number; i++){
                if(i % 3 == 0){
                    Console.WriteLine("*");
                }else{
                    Console.WriteLine(i);
                }
            }
            Console.WriteLine(number);
        }
    }
0
i’ve done 3 free test, but it shows that i have mistake in pro tests. don’t know what to do
0
using System;
using System.Collections.Generic;
namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            int number = Convert.ToInt32(Console.ReadLine());
           
            for(int i =1;i<=number;i++)
            {           
              string j = i.ToString();
           
                 j = (i%3==0)?  "*"  :  j ;
            
                    Console.Write(j);  
            }
         
        }
    }
}
0
@Elias Prado I wrote exactly your code and the tests pass, but I get an error message that the code is wrong.
This is the code I wrote:
namespace test3
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = Convert.ToInt32(Console.ReadLine());
            for (int x = 1; x < num ; x++)
            {
                if (x % 3 == 0)
                {
                    Console.Write('*');
                }else Console.Write(x);
            }
            Console.Write(num);
        }
    }
}



