Product of 10 numbers

  • 3
  • unavailable
Do you think you can easily multiply ten consecutive numbers from 1 to 10 in your mind? If this seems easy to you, you've probably never tried it. Here's a hint: the product is not a small number; it's more than three million. But this is easy for a computer: the important thing is to tell it how to do it.
You can't complete this task, because you're not signed in.
Comments(12)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Deborah WenrichLevel 4 , Pembroke Pines
5 November, 22:42
int z is my friend, i made it do all the work.
Brandon MillerLevel 5 , Burbank
11 September, 02:22
pretty sure i'm doing this correctly but it's saying the "displayed number must match the task conditions", i don't get it:
RomanLevel 41
11 September, 06:29
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
Justin SmithLevel 8
17 August, 01:14
I just wanted to take a moment and explain the "for loop" for you guys since there seems to be some confusion. Yeah, you aren't there yet in the lesson, but there's no harm in learning. The for loop starts with the "for" identifier. Inside of the parentheses are your statements. There are 3 different statements. The first statement (the int, i, in this example) runs once before the code block starts, and only once, and is where you declare a variable you want to work with, and set its value. The second statement is how many iterations you want to loop through, or how many times you want the code to run. In this example, you want the code to run as long as i is less than or equal to 5. Think of it as saying "I want to run this code while this statement is true". Since your int, i, is less than or equal to 5, it will execute. The or in that last sentence is important, and I will get to why. Your third statement increments, or adds, to your original variable by however much you wish, in this example it is 1. The ++ operator says add 1 to this variable, without needing to write everything out. It is very useful! The 3rd statement executes at the end of your code. Meaning, after the IDE prints "Yeet", it will increment i by 1. 1 2 3 for (int i = 0; i <=5; i++){ System.out.println("Yeet"); } Keep in mind that this code will execute 6 times! Why? Because you started at 0, you have 2 conditions, and it will run once before executing the increment in the 3rd block! Remember, the first statement runs once at the very beginning of the loop, the second statement checks if the condition (i <= 5) is still true, runs your code, and then the third statement increments i by 1. What are the two conditions? The <= means you are checking something twice; it says run this code if my number is less than OR equal to the number. Since 5=5, that statement is still true and the code will run!
Tara EdwardsLevel 6
29 July, 20:01
those dang semicolons get me everytime! ACK
LumoLevel 15 , Chisinau
11 June, 11:57
remember about how factorials work, you can build an easy for loop.
Clarence L MackeyLevel 4 , Fresno
11 June, 03:58
I wanted to add more but the compiler would not let me
ThomasLevel 7 , Scottsdale
20 May, 20:27
See Help from Raivo ( he got me through this ) --- https://codegym.cc/dialogues/46473
amaralLevel 4 , Delhi
22 October 2018, 10:32
whats wrong with this code my output is 3110400 and it does not match with the task plzz help me
RomanLevel 41
23 October 2018, 05:58
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
devikaLevel 4 , Hyderabad
20 January, 14:05
use for loop friend so that you will achieve
AustinLevel 6 , Lansing
24 April, 19:18
Or just multiply. Why work harder than you have to?