Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Solve(args) {
- var x = parseInt(args[0]);
- var y = parseInt(args[1]);
- var z = parseInt(args[2]);
- var n = parseInt(args[3]);
- var result;
- if (n === 1) {
- result = x;
- }
- else if (n === 2) {
- result = y;
- }
- else if (n === 3) {
- result = z;
- }
- else {
- for (var i = 4; i <= n; i++) {
- var temp = x + y + z;
- x = y;
- y = z;
- z = temp;
- }
- result = temp;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement