zoukankan      html  css  js  c++  java
  • 47.1+2+3+...+n(python)

    题目描述

    求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
    1 # -*- coding:utf-8 -*-
    2 class Solution:
    3     def Sum_Solution(self, n):
    4         # write code here
    5         return 1 if n==1 else n+self.Sum_Solution(n-1)

    2019-12-27 17:01:06

  • 相关阅读:
    11.10
    11.9
    11.8 总结
    11.7
    11.6
    日报10.6
    日报10.5
    每周总结-3
    日报10.4
    日报10.2
  • 原文地址:https://www.cnblogs.com/NPC-assange/p/12108327.html
Copyright © 2011-2022 走看看