0060【Edabit ★☆☆☆☆☆】【世纪危机】Century Crisis

编程入门 行业动态 更新时间:2024-10-09 06:28:21

0060【Edabit ★☆☆☆☆☆】【世纪<a href=https://www.elefans.com/category/jswz/34/1761104.html style=危机】Century Crisis"/>

0060【Edabit ★☆☆☆☆☆】【世纪危机】Century Crisis

0060【Edabit ★☆☆☆☆☆】【世纪危机】Century Crisis

algorithms loops math

Instructions

Scientists have discovered that in four decades, the world will EXPLODE! It will also take three decades to make a spaceship to travel to a new planet that can hold the entire world population.

You must calculate the number of people there will be in three decades from now.

  • The variable population is the world population now.
  • Assume that every month, someone gives birth to more people n.

Return the number of people there will be when the spaceship is complete.

Examples
futurePeople(256, 2) // 976
futurePeople(3248, 6) // 5408
futurePeople(5240, 3) // 6320
Notes
  • Humanity’s fate lies in your calculation.
Solutions
function futurePeople(population, n) {return population + 30*12*n;
}
TestCases
let Test = (function(){return {assertEquals:function(actual,expected){if(actual !== expected){let errorMsg = `actual is ${actual},${expected} is expected`;throw new Error(errorMsg);}},assertSimilar:function(actual,expected){if(actual.length != expected.length){throw new Error(`length is not equals, ${actual},${expected}`);}for(let a of actual){if(!expected.includes(a)){throw new Error(`missing ${a}`);}}}}
})();Test.assertEquals(futurePeople(256, 2), 976)
Test.assertEquals(futurePeople(3248, 6), 5408)
Test.assertEquals(futurePeople(5240, 3), 6320)

更多推荐

0060【Edabit ★☆☆☆☆☆】【世纪危机】Century Crisis

本文发布于:2023-11-17 10:44:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641640.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:危机   世纪   Edabit   Century   Crisis

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!