Sum from 1 to n in one line Python
<p>Given number <code>n</code>, I need to find the sum of numbers from <code>1</code> to <code>n</code>.
Sample input and output:</p>

<pre><code>100
5050
</code></pre>

<p>So I came up with <code>print(sum(range(int(input())+1)))</code> which solves the problem in one line but takes a long time since it's <code>O(n)</code>. Clearly, if we know the number <code>n</code> then the answer can be given in one line too: <code>print(n * (n+1) / 2)</code> but how to replace <code>n</code> with <code>input()</code> to still make program work?</p>