62552023-11-09 14:31:11RedStarDiana and NumberscsharpCompilation error
public class Run
{
    public static void Main(string[] args)
    {
        long userInput = -1;

// Get the user input
        userInput = long.Parse(Console.ReadLine());

        string numberAsString = userInput.ToString();


        while (true)
        {
            // If number has leading zeroes, remove them
            while (numberAsString.Length > 0 && numberAsString[0] == '0')
            {
                numberAsString = numberAsString.Remove(0, 1);
            }
    
            // If there is no number inside the variable, the user given number is impossible to make dividable by 3.
            if (numberAsString.Length == 0)
            {
                numberAsString = "-1";
                break;
            }
    
    
            // If number is dividable by 3, end the main cycle
            if (long.Parse(numberAsString) % 3 == 0)
            {
                break;
            }
    
            // Find the index of the first digit that's not dividable by 3.
            int index = -1;
            for (int i = 0; i < numberAsString.Length; i++)
            {
                if (numberAsString[i] % 3 != 0)
                {
                    index = i;
                    break;
                }
        
            }
            // Remove the digit from the whole number
            numberAsString = numberAsString.Remove(index, 1);

        }

        Console.WriteLine(numberAsString);


    }
}
Compilation error
exit status 1
Compilation failed: 2 error(s), 0 warnings