+ 1
Adding numbers
Question: instead of adding each number Manuel like this: 1 2 3 4 5 6 7 8 9. Is it possible to make a code that keeps adding 1 to the number and how?
18 Answers
+ 3
I saw this on discord lol.
Okay, so what you need to do is provide me with sample input and sample output.
+ 3
So your input is:
"1 2 3 4 5 ... 98 99 100"
And your output is:
"5050"
+ 1
So basically, what do you want to enter as input and what do you want to get as a result?
+ 1
Sure, just use a loop.
<?php
for($i=1;$i<=10;$i++){ //increase number by one until 10
echo $i; //print number
echo " "; //print space
}
?>
output:
1 2 3 4 5 6 7 8 9 10
+ 1
A simple For loop that keeps incrementing by 1 should do.
In Lua the code would be the following:
for i = 1, 100 do
print(i)
end
+ 1
You can embed php in html.
Or you can do it with Javascript.
Please have a look at the teaching section there the basics of these languages is explained
+ 1
This would be the code if you want it in HTML.
Write the following in Javascript:
document.write("<p style='font-weight:bold'>");
for(i=1;i<=100;i++)
{
document.write(i);
document.write("<br/>")
}
document.write("</p>");
+ 1
let me try
+ 1
what im really trying to is make a select property with numbers from 1900 up to 2018 to a registration for age. just gonna learn it from sololearn them self. thanks for helping👍💪
0
just wanted to get a fast answer lol 😂🤣.
aaaaaand. i have no idea what you are taking about
0
like 1 and 10?
0
just want to have the first number to be one and the last number to be 100 without whriting it manuel
0
like 1 2 3 4 5 up to 100
0
sorry man i dont think you understand. instead of whriting <p> 1 2 3 4 5.... 100 </p> can you just whrite a code that does that for you?
0
thanks
0
is it possible to do in Html, css or javascript?
0
can i use this in html, css or javascript
0
matthias okay thanks for the help. im quick trying Aatif’s solution if it works it works. if it do not work somethings wrong with me and im just gonna wait until sololearn learns me how to do 😂🤣