当前位置:网站首页>Sword finger offer 64 Find 1 + 2 +... + n
Sword finger offer 64 Find 1 + 2 +... + n
2022-07-18 11:09:00 【Ding Jiaxiong】
subject
seek 1+2+…+n , The requirement is not to use Multiplication and division 、for、while、if、else、switch、case Wait for keywords and conditional statements (A?B:C).
Example 1:
Input : n = 3
Output : 6
Example 2:
Input : n = 9
Output : 45
Limit :
1 <= n <= 10000
Answer key
class Solution:
def sumNums(self, n: int) -> int:
return n and (n + self.sumNums(n-1))

边栏推荐
- 實驗五 圖像分割與描述
- 你没有抓住 Promises 的要点
- npm ERR! CB () never called processing method
- Application of generator mode
- Design of DC motor control system
- 基于555定时器的呼吸灯电路
- Usage and difference between sizeof and strlen in C language
- redis之redis概念、配置、Sentinel高可用
- Electric quantity indicating circuit based on ADC0832
- wireshark 抓包调试(三路握手、四路断开)
猜你喜欢
随机推荐
Pytorch分布式训练
STL next_ Analysis of the return value of permutation() function
Written at the end of the recruitment of Huazhong University of science and technology
【Unity3D】UGUI之Slider
The relationship between loss function and maximum likelihood estimation | understanding of cross entropy
第17章 OAuth2LoginAuthenticationWebFilter 源码解析
The Institute of standardization issued the requirements for cloud migration related capabilities, and Wanbo Intelligent Cloud participated in the requirements and white paper preparation
基于Fitnesse的验收测试实验
Algorithm In Interview
C 语言基础双指针移除元素解法
一文读懂软件测试的常见分类
OLED循环显示图片文字
子集和问题
C语言 sizeof 和strlen 的用法和区别
redis之redis概念、配置、Sentinel高可用
Lombok introduction
js 数组对象中goods_id相同和并一个对象,把goods_size_id值添加一起
2022-07-15:一开始有21个球,甲和乙轮流拿球,甲先、乙后, 每个人在自己的回合,一定要拿不超过3个球,不能不拿。 最终谁的总球数为偶数,谁赢。 请问谁
问题 V: hannnnah_j’s Biological Test
Deployment practice of skywalking test environment








