LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Product of first N odd numbers

Solved!
Go to solution

Hello,

 

I tried quite a bit to solve this problem and I can't find the solution for the odd ones. It doesn't take my last term. I need some help.

Create a * .vi for calculating the sum of the first N even numbers and the product of first N odd numbers.

 

Here is what I get. The EVEN sum is good, but cant figure it out how to get the correct odd product.

0 Kudos
Message 1 of 20
(4,441 Views)

What is "Numeric" supposed to represent?  A max number?  Number of elements to process?


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 2 of 20
(4,428 Views)

If you see my photo, numeric is N. For N=5 we will have first 5 numbers. Sum of even is 0+2+4=6, product of odd should be 1*3*5=15. If I have N=7 sum of even 0+2+4+6=12 product should be 1*3*5*7=105.

0 Kudos
Message 3 of 20
(4,415 Views)

What is the result if you change '-1' to '+1'?

0 Kudos
Message 4 of 20
(4,403 Views)

For N=0 I get 1, for N=4 I get 15, N=5 for N=6 I get 105, N=7 it is also 105. So still wrong.

0 Kudos
Message 5 of 20
(4,398 Views)

snip.png

Message 6 of 20
(4,373 Views)

 

snip.png

Message 7 of 20
(4,372 Views)

... the increment should be outside of the loop

0 Kudos
Message 8 of 20
(4,369 Views)

I think numeric Q&R by 2 before the for loop is wrong. floor(2/2) = 1 and floor(3/2) = 1, so you will not get different results for numeric = 2 and numeric =3.

 

Sum%20Product

Message 9 of 20
(4,359 Views)
Solution
Accepted by topic author SebiC98

@Martin_Henz wrote:

 

snip.png


Slightly simpler, same result 🙂 :

 

altenbach_0-1604089888740.png

 

Message 10 of 20
(4,345 Views)