our task is to make function, which returns the sum of a sequence of integers. The sequence is defined by 3 non-negative values: begin, end, step. If begin value is greater than the end, function should returns 0.
sequenceSum(2,2,2) === 2
sequenceSum(2,6,2) === 12 // 2 + 4 + 6
sequenceSum(1,5,1) === 15 // 1 + 2 + 3 + 4 + 5
sequenceSum(1,5,3) === 5 // 1 + 4
const sequenceSum = (begin, end, step) => {
if (begin > end) {
return 0;
}
return begin + sequenceSum(begin + step, end, step);
};
<<: 第 27 型 - 路由 (Router) - 参数传递
>>: 仿Trello - Apollo client cache 操作
Youtube 影片 : 影片介绍如何使用 dotnet cli 打包 .net 开发程序,建立单一...
上次看的电脑萤幕程序 rom/programs/monitor.lua 还有一段特别的写法,是关於 ...
不敢相信今天是第30天了! 我完赛了!好感动啊~ 真的很感谢帮过我的老师/助教/同学/亲友…很多啦...
这篇文章使用LabVIEW配合MyRIO进行步进马达的控制,我使用的步进马达是小颗的那种,如果要用扭...
好的,连假最後一天,我们来个小篇章,就是Span啦,Span可以做到的事情有很多,如 *更改特定位...