Question: C++ code to find perfect number using recursion according to given google test cases Kindly solve this error.OR Write a program according to given google

C++ code to find perfect number using recursion according to given google test cases

Kindly solve this error.OR Write a program according to given google test cases

PROGRAM(HEADER):

#pragma once #include #include using namespace std;

bool isperfectNumber(int num, int x = 0) { //int x=0; if (x == 1) return 1;

else if (num % x == 0)/*if x is a proper divisor*/ { return x + isperfectNumber(num, x - 1); } else { return isperfectNumber(num, x - 1); } if (isperfectNumber(num, num / 2) == num) return false; else return true;

}

GOOGLE TEST CASES:

TEST(PerfectNumber, Test1) { ASSERT_EQ(true, isperfectNumber(28)); }

TEST(PerfectNumber, Test2) { ASSERT_EQ(false, isperfectNumber(17)); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!