From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Random number generator. Even and odd numbers

Solved!
Go to solution

I have a problem.

 

I have a random number generator, it goes from 0 to 20, I need to have two indicators, one will show how many numbers are pairs, and how many are not.

 

I tried to use the decimated 1D array, but since those numbers are random, it doesn´t work for me. I´m new with LabView, and I don´t know if there is some other way to make it work, I need some help, especially with some examples.

 

Thank you so much.

0 Kudos
Message 1 of 24
(3,837 Views)

Hi,

 

Your thread title says "Even and Odd numbers", but your description of the problem states 'pairs'.

 

Can you clarify exactly what you are trying to do.

 

Thanks

0 Kudos
Message 2 of 24
(3,817 Views)

What do you mean by "pairs"?  Just that a number is duplicated or that you have two of the same number back to back?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 24
(3,811 Views)

Hi.

 

I need to indicate how many numbers are even and how many are odd

 

Thanks.

0 Kudos
Message 4 of 24
(3,766 Views)

I need to indicate how many numbers are even and how many are odd

 

Thanks.

0 Kudos
Message 5 of 24
(3,765 Views)

I don't think your issue is necessarily with LabVIEW, although your unfamiliarity with it might distract you from what you really need to do.  Have you thought up of how you would do it on paper yet?  Maybe base your sorting on whether or not dividing by two leaves a remainder?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 24
(3,753 Views)

 

Spoiler

Create the array.  Use quotient remainder to divide by 2.  Now you have an array where all the odd numbers are now 1, and all the even numbers are now 0.  Sum the array and you have the total number of odd numbers.  The number of evens will be the length of the array divided by the # of odds.

 

Message 7 of 24
(3,752 Views)

@RavensFan wrote:

 

Spoiler

Create the array.  Use quotient remainder to divide by 2.  Now you have an array where all the odd numbers are now 1, and all the even numbers are now 0.  Sum the array and you have the total number of odd numbers.  The number of evens will be the length of the array divided by the # of odds.

 


Haha I lost sight of the fact that he was looking for the amount off odds and evens.  Good one.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 24
(3,741 Views)
Typically it is more efficient to do a bitwise AND with 1. You get zero for even and one for odd.

How are you generating the random numbers?
Message 9 of 24
(3,726 Views)

@RavensFan wrote:

 

Spoiler

Create the array.  Use quotient remainder to divide by 2.  Now you have an array where all the odd numbers are now 1, and all the even numbers are now 0.  Sum the array and you have the total number of odd numbers.  The number of evens will be the length of the array divided by the # of odds.

 



"The number of evens will be the length of the array divided by the # of odds."......you mean subtracted not divided?

0 Kudos
Message 10 of 24
(3,720 Views)