Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int squares(int num) {
- while (num >= 1) {
- if (num == 1){
- return 1;
- }
- else
- {
- return (pow(num , 2) + squares(num - 1));
- }
- }
- }
- int main() {
- int num;
- cout << "Enter the number you want to sum the series up to!\n";
- cin >> num;
- cout << "your sum of series " << squares(num);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement