Advertisement
bai_onzi

sequence

Jun 29th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let [K, N] = gets().split(' ').map(Number);
  2.  
  3. let sec = [K];
  4.  
  5. for(let i = 1; i < N; i++){
  6.     let curr = sec[i - 1];
  7.     sec.push(curr + 1);
  8.     sec.push(2 * curr + 1);
  9.     sec.push(curr + 2);
  10. }
  11. console.log(sec[N-1]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement