@ -55,6 +55,9 @@ char *to_string(int number)
}
unsigned int power(unsigned int b, unsigned int n){
if(b==0&&n==0) return 0;
else if(b>=1&&n==0) return 1;
else{
unsigned int result = 1, ctr = 0;
while(ctr<n){
result *= b;
@ -62,6 +65,7 @@ unsigned int power(unsigned int b, unsigned int n){
return result;
unsigned int toUnsignedInteger(char *ID)
{
@ -43,7 +43,7 @@ void test_power()
/*test block 5*/
int testValues_5[] = {0,0,19,2,4,5,11,54,32,12,77};
int exponents[] = {0,1,2,7,4,2,0,1,2,4,2};
int expectedValues_5[] = {-1, 1, 361,128,256,25,1,54,1024,20736,5929};
int expectedValues_5[] = {0, 0, 361,128,256,25,1,54,1024,20736,5929};
length = sizeof(testValues_5)/sizeof(int);
for(int i=0;i<length;++i){
TEST_ASSERT_EQUAL_INT(expectedValues_5[i], power(testValues_5[i],exponents[i]));