How to identify even or odd numbers

How to identify even or odd numbers along with best practices of Ui path.
Thanks and regards from our

Hi @Abhilash_Yadav

Can you try this

CInt(str_Input) Mod 2 = 0

Regards,

i want to get the input from myself each time i want to give different numbers

@Abhilash_Yadav

How about the following?

Or If you want to give multiple numbers then try below

Or If you are having an array of numbers then try below

Regards,

1 Like

@Abhilash_Yadav

Welcome to Community!!

To achieve your process, follow the below methods,

  1. Use Input dialogue box to get the Input from your side/any user, store it in the string variable
  2. Check the that user input is number or not for that you can use this expression in if condition(isnumeric(strUserInput))
  • In Then sequence convert that string to int for that take one assign activity, create one int var and provide that input in To section and in value use Cint(strUserInput)
  • after assign acitivty use one more if activity to check given number is Even or odd for that use intVar mod 2 =0
  • in then, print a log message stating that given input was Even Number
  • in else condtion, use one more log message activity stating that given number is Odd Number.

3.In Else Branch, Use a log message that given input was not in correct format.

If you are familiar with try catch you can implement this in Try catch activity.

Happy Automation!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.