I'm getting this 362880 that is correct as I googled it.
but condition says ain't right as it is not more than three million.
Any suggestions?
Confused !
Resolved
Comments (12)
- Popular
- New
- Old
You must be signed in to leave a comment
Okanlawon Oluwatobi Damilare
11 March 2019, 18:38
public class Solution {
public static void main(String[] args) {
//write your code here
System.out.print(product(10));
}
public static int product(int i){
if(i <= 1){
return 1;
}else{
for(int x = 1; x <= 10; x++){
i = i * x;
}
}
return i;
}
}
0
divya
15 February 2019, 07:31
public static void main(String[] args) {
//write your code here
int a=1*2*3*4*5*6*7*8*9*10;
System.out.println(a);
hope this helps:)
0
Sjet Nj
27 January 2019, 11:33
package com.codegym.task.task03.task0308;
/*
Product of 10 numbers
*/
public class Solution {
public static void main(String[] args) {
System.out.println(mul(1));
}
public static int mul(int a){
for(int i=1;i<=10;i++)
a=a*i;
return a;
//write your code here
}
}
0
dD
18 January 2019, 08:07
Let me just tell you that you actually have to write a new method, and in that method for loop needs to be, and then you call it from main method. I did everything right and got the right number but did it all in main method, so the system recognized it as not valid even tho its not specified that it cant be in main, hope that this helps someone who made same mistake :)
+1
Fadi AlSaidi
31 October 2018, 02:42
I don't recall every running into loops or loops lessons!
did I miss some lessons?
+1
TomJack
25 October 2018, 15:09
public static int multiply(){ //int have to be add
int i =1;
for(int ii=1;ii<10;ii++){
i *=ii;
}
return i;
}
0
Loay Alkhalaf
26 October 2018, 03:16
did this workout for you?
0
rsingh04
16 October 2018, 08:45
its 3628800, use i<=10 not i<10
+2
Khurram
24 September 2018, 16:09
the product of numbers 1-10 is 3,628,800
+2
Ankush Rajput
24 September 2018, 15:55
Share your code here. How can anyone point out mistakes or give suggestions with looking at your code ?
+1
Anwaar ul haq
24 September 2018, 17:04
0
Ankush Rajput
24 September 2018, 17:07solution
in for loop, you've written a<10. It means it will run from 1-9. We want it to run from 1-10 and multiply.
+4