Skip to content

Instantly share code, notes, and snippets.

@penut85420
Last active November 20, 2017 08:53
Show Gist options
  • Save penut85420/a301951d561fe18685c7e3cb5dc2d38e to your computer and use it in GitHub Desktop.
Save penut85420/a301951d561fe18685c7e3cb5dc2d38e to your computer and use it in GitHub Desktop.
Splite num sequence
package com.Test;
public class Num123 {
public static void main(String[] args) {
int n = 5;
foo(2, n, "1");
}
public static void foo(Integer i, Integer n, String s) {
if (i == n) {
log(s + " " + i.toString() + "\n");
log(s + i.toString() + "\n");
return ;
}
foo(i + 1, n, s + " " + i);
foo(i + 1, n, s + i.toString());
}
public static void log(Object obj) {
System.out.print(obj.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment