Skip to content

Instantly share code, notes, and snippets.

@tonkatsu7
Created July 10, 2018 06:53
Show Gist options
  • Save tonkatsu7/f7bf67dd646bf20e5eeafdfd338f4f3a to your computer and use it in GitHub Desktop.
Save tonkatsu7/f7bf67dd646bf20e5eeafdfd338f4f3a to your computer and use it in GitHub Desktop.
CoderByte challenge Simple Adding
import java.util.*;
import java.io.*;
class Main {
public static int SimpleAdding(int num) {
return (num == 1) ? 1 : num + SimpleAdding(num - 1);
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(SimpleAdding(s.nextLine()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment