Write program to calculate product of all odd numbers from 1 to 15 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write program to calculate product of all odd numbers from 1 to 15

Use while loop

18th Jul 2018, 10:44 PM
Abby
Abby - avatar
17 Answers
0
use while
19th Jul 2018, 8:39 AM
Abby
Abby - avatar
+ 5
import numpy as np x=np.array(np.arange(1,16,2)) print(x.prod())
19th Jul 2018, 3:49 AM
Louis
Louis - avatar
+ 4
Abigael Irene Nyangasi Users have answered you too much... They have showed you how handle only odd numbers and how multiply they... Instead of post "use while", why you dont try to solve this problem yourself?
19th Jul 2018, 8:42 AM
KrOW
KrOW - avatar
+ 3
yeah, otherwise probably no ones gonna answer him since programming is not ment to simply copy paste
18th Jul 2018, 11:05 PM
Roel
Roel - avatar
+ 2
i think he wants us to answer how to do that in c# since its his only course and he is probably too lazy to try it himself
18th Jul 2018, 11:01 PM
Roel
Roel - avatar
+ 2
He have to post his work just for make sure that he dont want his homework made from others
18th Jul 2018, 11:04 PM
KrOW
KrOW - avatar
+ 1
//Kotlin fun main(args: Array<String>) { // Using reduce println((1..15 step 2).reduce{x, y -> x*y}) // Using fold println((1..15 step 2).fold(1){x, y -> x*y}) }
19th Jul 2018, 5:14 AM
Ferhat Sevim
Ferhat Sevim - avatar
+ 1
yeah and for this situation for is easier
19th Jul 2018, 9:15 AM
darkorbit17493
+ 1
Abby If i tell you this is because your behaviour make believe me that you want only code from other users without apply yourself P.S. Set as best answer your comment its ridiculous and inappropriate above all considerating other users that tried to help you
19th Jul 2018, 11:03 AM
KrOW
KrOW - avatar
0
What language?
18th Jul 2018, 10:48 PM
Disvolviĝo;
Disvolviĝo; - avatar
0
Abigael Irene Nyangasi Where is your code?
18th Jul 2018, 10:50 PM
KrOW
KrOW - avatar
0
int result; for(int i=0;i<=15;++i){ if(i%2==1){ result+=i; } } cout<<result;
19th Jul 2018, 8:19 AM
darkorbit17493
0
sorry for the bad english :)
19th Jul 2018, 9:18 AM
darkorbit17493
0
KrOw am good okay... i got it
19th Jul 2018, 9:20 AM
Abby
Abby - avatar
0
Don't be hard on me its a learning process okay
19th Jul 2018, 9:24 AM
Abby
Abby - avatar
0
Thanks
19th Jul 2018, 11:20 AM
Abby
Abby - avatar
0
i = 1 mul = 1 while i <= 15: mul *= i i += 2 print(mul)
21st Jul 2018, 11:31 PM
yang gang