First of all, do NOT post complete or partial solutions, only help. Second of all, I am having trouble implementing the recursive function in 2 homework programs I'm doing.
The first one sums multiples of 3, and the second one does combinations (number choose number) but I have no clue how to implement it. I have tried by myself, but both programs are a disaster.
Code:
#include <iostream>
using namespace std;
int sum3s(int sum) {
if(sum == 1) {
return 0;
}
else if (sum / 3 + 1 && 3 + 2 && 3 + 3 == 3) {
return 1 + 3 + 2 + 3 + 3 + 3 * sum3s(3 * 3 * sum);
}
}
int main ( ) {
int number;
cout << "Enter number: ";
cin >> number;
cout << "" << endl;
cout << "The sum is " << sum3s(number);
cout << ".";
}
Code:
#include <iostream>
using namespace std;
int combinations (int n, int k) {
if (n == 1) {
return 1;
}
else {
return combinations(n + k + n + k + n + k);
}
}
int main ( ) {
int a;
int b;
cout << "Enter an Integer: ";
cin >> a;
cout << "Enter another Integer: ";
cin >> b;
cout << "Combinations( " << a "," << b ")" " = ";
cout << combinations(a, b);
}