+ 1
Write program to calculate product of all odd numbers from 1 to 15
Use while loop
17 Antworten
0
use while
+ 5
import numpy as np
x=np.array(np.arange(1,16,2))
print(x.prod())
+ 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?
+ 3
yeah, otherwise probably no ones gonna answer him since programming is not ment to simply copy paste
+ 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
+ 2
He have to post his work just for make sure that he dont want his homework made from others
+ 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})
}
+ 1
yeah and for this situation for is easier
+ 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
0
What language?
0
Abigael Irene Nyangasi Where is your code?
0
int result;
for(int i=0;i<=15;++i){
if(i%2==1){
result+=i;
}
}
cout<<result;
0
sorry for the bad english :)
0
KrOw am good okay...
i got it
0
Don't be hard on me its a learning process okay
0
Thanks
0
i = 1
mul = 1
while i <= 15:
mul *= i
i += 2
print(mul)