Hey may i know how to sum up a number up to infinity by 1?

how to do the code for repeated addition of a number by 1?

int numberofthings =0;
while (true)
{
 numberofthings++;
}

Canned message to you that may help you help us.

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Please post a schematic.
Please post an image of your project.
Please describe the problem better then you just did.

1 Like

??????????? make your question more clearly.

for(uint16_t cnt = 0; cnt<65535; cnt++){

}
1 Like

Up to infinity is impossible. With integral types you'll run into an overflow, with floating point types adding 1.0 will stop incrementing at some high value.

Without infinity the answer is simple:
x++;
will increment x.

Clearly infinity is impossible, but for all practical purposes, you can create a sum (easily) that's only limited by the amount of available RAM.

You could do it in Flash, but you'd exceed the write limit before you got close to the maximum number :slight_smile:

1 Like

@alexchanyanquan

Your other topic on the same subject deleted.

Your topic moved to programming questions. Please do not post your questions in the tutorial section of the forum.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Depends, do you want to work smart or hard?
If you know how far that you want to go, you can convert the series into an equation.
for 1-100:
1+100 = 101
2+99 = 101
So, each pair = 101 and you have 100/2 or 50 pairs.
The sum of all is 101 * 50 or 5050.

As far as adding to infinity, that is ill advised, unless you're Buzz Lightyear

as a prelimary exercise

1 Like

Will you still be alive when it gets to infinity?

Until the parallel lines intersect

1 Like

If you are, just add 1

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.