【Kata Daily 191010】Grasshopper - Summation(加总)
题目:
Summation
Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0.
For example:
summation(2) -> 3
1 + 2
summation(8) -> 36
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8
解题方法:
很简单的题目:
def summation(num):
return sum([x for x in range(num+1)])
【Kata Daily 191010】Grasshopper - Summation(加总)的更多相关文章
- 【Kata Daily 190920】Square(n) Sum(平方加总)
题目: Complete the square sum function so that it squares each number passed into it and then sums the ...
- 【Kata Daily 190929】Password Hashes(密码哈希)
题目: When you sign up for an account somewhere, some websites do not actually store your password in ...
- 【Kata Daily 191012】Find numbers which are divisible by given number
题目: Complete the function which takes two arguments and returns all numbers which are divisible by t ...
- 【Kata Daily 190927】Counting sheep...(数绵羊)
题目: Consider an array of sheep where some sheep may be missing from their place. We need a function ...
- 【Kata Daily 190924】Difference of Volumes of Cuboids(长方体的体积差)
题目: In this simple exercise, you will create a program that will take two lists of integers, a and b ...
- 【Kata Daily 190923】Odder Than the Rest(找出奇数)
题目: Create a method that takes an array/list as an input, and outputs the index at which the sole od ...
- 【Kata Daily 190919】Sort Out The Men From Boys(排序)
题目: Scenario Now that the competition gets tough it will Sort out the men from the boys . Men are th ...
- 【Kata Daily 190918】Spacify(插空)
题目: Modify the spacify function so that it returns the given string with spaces insertedbetween each ...
- 【Kata Daily 190917】Numericals of a String(字符出现的次数)
题目: You are given an input string. For each symbol in the string if it's the first character occuren ...
随机推荐
- 079 01 Android 零基础入门 02 Java面向对象 01 Java面向对象基础 01 初识面向对象 04 实例化对象
079 01 Android 零基础入门 02 Java面向对象 01 Java面向对象基础 01 初识面向对象 04 实例化对象 本文知识点:实例化对象 说明:因为时间紧张,本人写博客过程中只是对知 ...
- Java知识系统回顾整理01基础05控制流程03 while
while和do-while循环语句 一.while:条件为true时 重复执行 只要while中的表达式成立,就会不断地循环执行 public class HelloWorld { public s ...
- Bayer Pattern——RGGB
原博客地址:https://blog.csdn.net/joe9280/article/details/46952947 参考:https://blog.csdn.net/wgx571859177/a ...
- 「DevOps 转型与实践」沙龙回顾第一讲
9 月 19 日,CODING 和中国 DevOps 社区联合举办的深圳第九届 Meetup 在腾讯大厦 2 楼多功能圆满结束.本次沙龙以 「DevOps 转型与实践」 为主题,4 位来自互联网.金融 ...
- DX12龙书 01 - 向量在几何学和数学中的表示以及运算定义
0x00 向量 向量 ( vector ) 是一种兼具大小 ( magnitude ) 和方向的量. 0x01 几何表示 几何方法中用一条有向线段来表示一个向量,其中,线段长度代表向量的模,箭头的指向 ...
- Docker 开启非认证的2375端口,提供外部访问 Docker
1.编辑 Docker 服务的配置文件 vi /usr/lib/systemd/system/docker.service 或者 vi /lib/systemd/system/docker.servi ...
- TMS, XYZ & WMTS的不同
WMS是OGC定义的协议,用于请求任意区域的渲染地图图像.客户可以根据需要以平铺模式对其进行请求. WMS-C是OSGeo创建的WMS扩展,它向功能文档中添加了元数据,以使客户端知道在哪里发出请求,从 ...
- jmeter_03_鉴权
jmeter权鉴* 1.配置节点 - 2.前置处理器 3.定时器 4.取样器 5.后置处理器(只在有结果的情况下执行) 6.断言(只在有结果的情况下执行) 7.监听器(只在有结果的情况下执行) 参数叠 ...
- 【logstash】 - 使用json解析数
ilter-json:http://www.logstash.net/docs/1.4.2/filters/json json数据: {"account_number":995,& ...
- go 接口实现
package main import ( "fmt" ) // 定义接口 type Beahavior interface { Run() string Eat(thing st ...