【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 ...
随机推荐
- C++中union的使用方法
转载:https://blog.csdn.net/hou09tian/article/details/80816445 1 概述 1.1 定义 union即为联合,它是一种特殊的类.通过关键字unio ...
- JS原生练习
1.输出1-10000之间的数 <script> for(i=1;i<=10000;i++) { document.write(i + "<br>") ...
- C# excel文件导入导出
欢迎关注微信公众号 C#编程大全 这里有更多入门级实例帮你快速成长 在C#交流群里,看到很多小伙伴在excel数据导入导出到C#界面上存在疑惑,所以今天专门做了这个主题,希望大家有所收获! 环境:wi ...
- Mybatis老手复习文档
Mybatis学习笔记 再次学习Mybatis,日后,有时间会把这个文档更新,改的越来越好,然后,改成新手老手通用的文档 1.我的认识 Mybatis 是一个持久层框架,(之前 我虽然学了这个myba ...
- C语言的污垢,一个能污染内存的神秘操作!神级坑位再现~
本文目的是为了更好的理解指针和内存管理 背景 我们定义一个变量A,修改另外一个一个变量B,导致A的值被修改,我们称它为内存污染. 案例 如下程序,正常的预期输出应该是:97 98 256 ,但正确的结 ...
- 落地Azure CosmosDb的一个项目分享
我们遇到了什么? 我们有这么一个业务场景,就是某供应商会去爬取某些数据,爬到后会发到一个FTP上,然后我们定时去获取这些数据 这个数据有大有小,小的30多M数据量百万级,大的数据量能到数百M上千万数据 ...
- Redis6 安装
在centos7.5服务器上按照官方发布的安装方式并不能进行正确的安装,现收集并整理如下安装方式,亲测有效 1.安装依赖 yum install -y cpp binutils glibc glibc ...
- Vue3 来了,Vue3 开源商城项目重构计划正式启动!
我打算用 Vue3 写一个商城项目,目前已经开始着手开发,测试完成后正式开源到 GitHub,让大家也可以用现成的 Vue3 大型商城项目源码来练练手. Vue 3.0 来了,我们该做些什么? Vue ...
- SSM中 web.xml配置文件
<!--核心监听器 当tomcat(web容器,应用服务器,web服务器)启动的时候创建spring 工厂类对象,绑定到tomcat上下文中 --> <listener> &l ...
- 群晖DS218+做maven私服(nexus3)
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...