Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int rec13(int sum, int k, int depth) {
- if (depth > N)
- return -1;
- if (sum < 0)
- return -1;
- if (sum == 0) {
- System.out.print("\n" + k + " ");
- return 0;
- }
- for (int i = k; i <= sum; i = i + 2) {// Развлетляет рекурсию
- if (sum - i == 0) {
- return rec13(sum - i, i, depth + 1);
- }
- int res = rec13(sum - i, i, depth + 1);
- if (res == 0) {
- System.out.print(i + " ");
- //return 0;//распечатает только первую но полностью
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement