Jump to content

Cálculo de Mínimo Múltiplo Comum


anficori
 Share

Recommended Posts

Boas Pessoal,

estou com um problematizo e precisava da vossa ajuda,

Dado um número com três algarismos calcula o mínimo múltiplo comum entre esses três algarismos.

       Dim a As Integer
       Dim b As Integer
       Dim c As Integer
       Dim um As Integer
       Dim dois As Integer
       Dim tres As Integer


       If (TextBox1.Text > 100 And TextBox1.Text < 999) Then

           tres = TextBox1.Text Mod 10
           dois = (TextBox1.Text / 10) Mod 10
           um = ((TextBox1.Text / 10) / 10) Mod 10


           For i = 0 To 9
               a = um * i
               For k = 0 To 9
                   b = dois * k
                   If (a = b) Then
                       For j = 0 To 9
                           c = tres * j
                           If (a = c And b = c) Then
                               Label1.Text = a
                           End If
                       Next
                   End If
               Next
           Next
       End If

Mas só calcula algumas vezes não dá sempre. e Se for inserido o numero 236, o resultado devia ser 6 e dá-me 12:S

alguém me pode ajudar ?

Obrigado

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.