10-30-2020 01:41 PM
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.
Solved! Go to Solution.
10-30-2020 02:00 PM
What is "Numeric" supposed to represent? A max number? Number of elements to process?
10-30-2020 02:07 PM
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.
10-30-2020 02:17 PM
What is the result if you change '-1' to '+1'?
10-30-2020 02:26 PM
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.
10-30-2020 02:53 PM
10-30-2020 02:55 PM
10-30-2020 02:57 PM
... the increment should be outside of the loop
10-30-2020 03:05 PM - edited 10-30-2020 03:05 PM
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.
10-30-2020 03:33 PM