LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you get the sum of even numbers from a 1D array

another way (without multiplication)

 

A_1.png

Message 11 of 19
(2,302 Views)

@ouadji wrote:

another way (without multiplication)


Qute! Here's what I had in mind.

 

 

0 Kudos
Message 12 of 19
(2,279 Views)

This is what I had in mind.

 

sum even elements.png

 

Ben64

0 Kudos
Message 13 of 19
(2,256 Views)

 

my way is faster (large array)  Smiley Wink  Smiley Tongue

 

A_1.png

0 Kudos
Message 14 of 19
(2,247 Views)

ouadji wrote:

my way is faster (large array)  Smiley Wink  Smiley Tongue


Yup, I arrived at the same code in the end.... 😄

 

0 Kudos
Message 15 of 19
(2,225 Views)

Thank you everyone for your hep. I have been able to get it done.

Spoiler
 
Message 16 of 19
(2,146 Views)

your code need some change
you have to add this at then end -1*( your last value -maximum number of array+1) /2

0 Kudos
Message 17 of 19
(2,135 Views)

@Hatef wrote:

your code need some change


There are quite a few code examples above. You need to be more specific. Ideally quote the post you are replying to.


Hatef wrote:

you have to add this at then end -1*( your last value -maximum number of array+1) /2


Why don't you show us some LabVIEW code instead?

Why would the last value matter? The sum does not depend on the order of elements.

The maximum number in the array is also irrelevant. Even if the max is 9999999, the sum will be zero if there are no even numbers.

Message 18 of 19
(2,125 Views)

Dear 

0 Kudos
Message 19 of 19
(2,088 Views)