# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Product of first N odd numbers

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.

Message 1 of 20
(2,919 Views)

## Re: Product of first N odd numbers

What is "Numeric" supposed to represent?  A max number?  Number of elements to process?   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
Message 2 of 20
(2,906 Views)

## Re: Product of first N odd numbers

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.

Message 3 of 20
(2,893 Views)

## Re: Product of first N odd numbers

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

Message 4 of 20
(2,881 Views)

## Re: Product of first N odd numbers

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.

Message 5 of 20
(2,876 Views)

## Re: Product of first N odd numbers Message 6 of 20
(2,851 Views)

## Re: Product of first N odd numbers Message 7 of 20
(2,850 Views)

## Re: Product of first N odd numbers

... the increment should be outside of the loop

Message 8 of 20
(2,847 Views)

## Re: Product of first N odd numbers

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. Message 9 of 20
(2,837 Views)
Solution
Accepted by topic author SebiC98

## Re: Product of first N odd numbers

@Martin_Henz wrote: Slightly simpler, same result 🙂 :  LabVIEW Champion. Message 10 of 20
(2,823 Views)