riffersfeast

task2

Jul 5th, 2021
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. package com.telerikacademy.dsa;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Scanner;
  5.  
  6. public class Sequence {
  7.  
  8. public static void main(String[] args) {
  9. Scanner scanner = new Scanner(System.in);
  10. String[] input = scanner.nextLine().split(" ");
  11. int k = Integer.parseInt(input[0]);
  12. int n = Integer.parseInt(input[1]);
  13.  
  14. ArrayList<Integer> list = new ArrayList<>();
  15. list.add(0, k);
  16. list.add(1, k + 1);
  17. list.add(2, 2*k +1);
  18. list.add(3, k + 2);
  19. list.add(4, k + 2);
  20. list.add(5, 2*k + 3);
  21. list.add(6, k+ 3);
  22.  
  23.  
  24. System.out.println(list.get(n-1));
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment