Check if each number is divisible by 2

Hello, this is my second time to ask here.

My question is: how can I check if each input number is all divisible by 2? My input for example is 246708, and I want to check if all of these numbers are divisible by 2.

I am thinking of putting the numbers first in a list and get each number one by one then do the operations. But I don't know how to do that in the mit app or is it best way of doing it? thanks for the help

So 246708 is not a single big even number that ends in 8 and is therefore even, but instead is a set of 6 single digit numbers that have to all be even?

If you need to check each digit, you could check using the text CONTAINS block.
Say the input text is in txbInput.Text so you could test for

  • if it contains '1' or
  • if it contains '3' or
  • if it contains '5' or
  • if it contains '7' or
  • if it contains '9'

then not all digits are even.

That's what you asked for, but it might not be what you want.
Is that what you want?

If you divide any number by 2 and the remained is zero mean it is declare that it is divisible by that no

2022-05-25_151011

2 Likes

You can use the CheckEven block in my MathTools Extension.

I should have asked this question first, before taking a stab at a "solution" ...

What exact response would you like your app to give when presented with that number, 246708?

If you want to check for each digit in the input number, here is what you have to do :

(You can drag and drop this image to the blocks area.)

Here is the .aia file :

Test.aia (24.4 KB)

I used my MathTools Extension to do this.

@SHUBHAMR69 you procedure goes through the loop and displays result for last item in loop. Check for example number 22221 if you actually want to use such a procedure you have to add true or false to a temp list and check if false exists in list

1 Like

Actually it sets the result to false if any of the digit is not even.

There is no such block in it to set the result to true, so for any odd digit, the result will be set to false, but for any even digit, nothing will happen.

If there is no odd digit, the default value, i.e., true, will be returned.

Hello @nobi
You can use use this
Answer ="number"/2
Answer =1 then odd
Answer = 0 then even

He wants to check if each digit is even or not. Not just the full number.

2 Likes