1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-02-05 07:00:25 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/设计机械累加器 [qiu-12n-lcof].html

28 lines
670 B
HTML
Raw Normal View History

2023-12-09 18:53:53 +08:00
<p>请设计一个机械累加器,计算从 1、2... 一直累加到目标数值 <code>target</code> 的总和。注意这是一个只能进行加法操作的程序不具备乘除、if-else、switch-case、for 循环、while 循环,及条件判断语句等高级功能。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong> target = 5
<strong>输出:&nbsp;</strong>15
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong> target = 7
<strong>输出:&nbsp;</strong>28
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= target&nbsp;&lt;= 10000</code></li>
</ul>
<p>&nbsp;</p>