public class Main
{
static String reverse(String s) {
if(s.length()==0)
return "";
return s.charAt(s.length()-1) + reverse(s.substring(0, s.length()-1));
}
static void onetoN(int i,int n) {
if(i>n)
return;
System.out.print(i+" ");
onetoN(i+1,n);
}
static int sum(int n) {
if(n==0){
return 0;
}
return n+sum(n-1);
}
public static void main(String[] args) {
System.out.println("Hello World");
String v=reverse("Hello World");
System.out.println(v);
System.out.println(sum(6));
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter