Selection of a non-random number in a C #

-2

My question is whether the following proposed exercise: "Task: Write an algorithm in VisualG or C # that receives two positive integer values (x and y) and tell whether x is divisible by y. Let's focus on the problem when y is 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15 or 25.

I would like a light from where to begin.

Once I have access to a computer I will edit the question with my code so far.

EDIT: Code so far:

 namespace  {
     class Program
     {
         static void Main(string[] args)
         {
             //declaração de Variaveis X e Y (onde y é fixa em valores pre definidos e x é dado pelo usuario)
             int x;
             int[,] y = new int [13, 0];
             y[1, 0] = 2;
             y[2, 0] = 3;
             y[3, 0] = 4;
             y[4, 0] = 5;
             y[5, 0] = 6;
             y[6, 0] = 7;
             y[7, 0] = 8;
             y[8, 0] = 9;
             y[9, 0] = 10;
             y[10, 0] = 11;
             y[11, 0] = 12;
             y[12, 0] = 15;
             y[13, 0] = 25;

             //introdução ao programa
             Console.WriteLine("Programa TESTE DE DIVISIBILIDADE");
             Console.WriteLine();
             Console.WriteLine("O programa tem por objetivo informar se um determinado numero é ou não divisivel por outro");
             Console.WriteLine();
             Console.WriteLine("Os testes de divisibilidade são validos para os seguintes divisores: 2,3,4,5,6,7,8,9,10,11,12,15,25");
             Console.WriteLine();
             Console.WriteLine("Aperte qualquer tecla para continuar:");
             Console.ReadKey();
             Console.Clear();

             //coleta de dados
             Console.WriteLine("Digite o Dividendo");
             x = Convert.ToInt32 (Console.ReadLine());
             Console.WriteLine("Digite o Divisor entre 2,3,4,5,6,7,8,9,10,11,12,15,25");
             y = Convert.ToInt32 (Console.ReadLine());


         }
     } 
}
    
asked by anonymous 08.11.2018 / 15:21

1 answer

0

Perhaps a static method is the best solution.

using System;

public class Program
{
  public static void Main()
  {
    Console.Write(IsDivisible(3,3));
  }

  public static bool IsDivisible(int x, int y)
  {
    return x % y == 0;
  }
}

Here's a online test !

    
08.11.2018 / 15:41