import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {

    public static void main(String[] args) {
       // System.out.println("Hello world!");
      Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int result =  SumOfN(n);
       System.out.println(+result); 
    }
public static int SumOfN(int n){
//if (n == 0 || n == 1) {return 1; }   // base condition to stop/exit logic
  if (n == 0 ) {return 0; }   //in case of addition
  
    return  n + SumOfN(n-1) ;  //main logic //sub problem
    
}
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: