# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Re: Product of first N odd numbers

Here is how I roll: Likely homework so explanations are left as an exercise for the reader...

Message 11 of 20
(787 Views)

## Re: Product of first N odd numbers

Of course one quickly runs out of digits and the entire thing could actually be implemented as a lookup table for all useful inputs.

A more interesting solution would be something that can produce results with thousands of significant digits. 😉 (look here for some ideas ) LabVIEW Champion. Message 12 of 20
(779 Views)

## Re: Product of first N odd numbers

Ok, that's the end of the line - slightly faster than I - needed too much time to think about the odd product 😮

Message 13 of 20
(777 Views)

## Re: Product of first N odd numbers

@altenbach wrote:

Of course one quickly runs out of digits and the entire thing could actually be implemented as a lookup table for all useful inputs.

A more interesting solution would be something that can produce results with thousands of significant digits. 😉 (look here for some ideas )

In this case I would go for something like phython with the mpmath library.

Message 14 of 20
(763 Views)

## Re: Product of first N odd numbers

For N=0 the product is 1. Thank you all for the solutions. I will check them all to understand them and to see which fits better.

Message 15 of 20
(759 Views)

## Re: Product of first N odd numbers

0 is an even number, so this is irrelevant for the problem. However if you want a product result of 1 if N=0, that can easily be implemented. Is zero even allowed as input for your problem. Hard to tell unless we know all the requirements. LabVIEW Champion. Message 16 of 20
(751 Views)

## Re: Product of first N odd numbers

If 0 is an even number the sum should be 0 and the product also 0.

Message 17 of 20
(747 Views)

## Re: Product of first N odd numbers

@SebiC98 wrote:

For N=0 the product is 1. Thank you all for the solutions. I will check them all to understand them and to see which fits better.

Here's the tiny change to fix this. See if you understand why. 😉

(The product of an empty array is of course also 1, so some of the conditional indexing solutions will probably work too)

(I also went to U64, but overflow still occurs if the numbers are getting a bit larger, of course)  LabVIEW Champion. Message 18 of 20
(741 Views)

## Re: Product of first N odd numbers

Thank you verry much. Have a great day!

Message 19 of 20
(736 Views)

## Re: Product of first N odd numbers

@SebiC98 wrote:

If 0 is an even number the sum should be 0 and the product also 0.

No. As I said 0 factorial is 1 and the product of an empty array is also 1, so the correct result for N=0 should probably be one, because the list of odd number is an empty array. See also my other answer. LabVIEW Champion. Message 20 of 20
(735 Views)