def exponents(num1,num2): if (num2==0): return 1 else: return num1*exponents(num1,num2-1) Hey I was wondering how I can generate a list of exponents using a for loop or a while loop so that the numbers display like this: Input (2,3) Output 2,4,8 What I have so far only returns the answer, Please assist if possible, I am really not getting the hang of this loop thing. |
+0 forum
4 | ||

Hey guys I have a program im doing for fun, I need to be able to enter a minimum exponent and a maximum exponent as well as a base. CANNOT USE THE POW() FUNCTION. Ex. minimum exponent = -2 maximum exponent = 3 base = 2 output: base exponent result 2 -2 0.25 -1 0.5 0 1 1 2 2 4 3 8 Here is what I have so far. [CODE] #include <iostream.h> void ExpPow(float &res, int base, int count); void negexp(float &res, int base, int count); int main() { int base; int expow; int expomax; int count; float res … |
+0 forum
6 | ||

Hi I have a problem with some code. Basically what the program is supposed to do is to take in a minimum exponent and a maximum exponent and a base. Then its is suppose to create a table displaying the base to the power of the minimum exponent to the max exponent.I have got the positive exponents to work but I cannot get the negative exponents to work. I cannot use the pow() function. ex.(this is what it should look like) input: Base = 2 max exponent = 3 min exponent = -2 output: .25 .5 1 2 4 8 … |
+0 forum
1 |

The End.