Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.  
  4.     public static int f(int n){
  5.         if (n==1)
  6.             return 1;
  7.         else
  8.             return f(n-1)+2;
  9.     }
  10.  
  11.     public static void main(String[] args) {
  12.         int n;
  13.         n = new Scanner(System.in).nextInt();
  14.         System.out.println(f(n));
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement