- **Software Development**
(*http://forums.techarena.in/software-development/*)

- - **Java math question**
(*http://forums.techarena.in/software-development/1240582.htm*)

Java math questioni need to make a method in which a for loop is used to calculate 2 exponent n. Does anyone know the math formula for mutiplying a number by an inferred exponent? i have this public static void powerOf() { //declare variables int num; int pwr; System.out.println("The powers using a for statement are: "); //for statement for( num = 1; num <11; ++num){ //squaring pwr =(2*num); System.out.println(" 2 to the power of "+ num + " is: " + pwr); } i need it so that when n is instantuated it is a power of 2 lets say soemthing liek 2 power 2 should be 4 and 2 power 3 is 8 etc.. |

Re: Java math questionI don't know about java but have a look at this C example using POW function: Code: `/* pow example */` Code: `/* exp example */` |

Re: Java math questionty for the reply but i figured it out. public static void exponential() { //declare variables double num; double cons = 2; System.out.println("The powers using a for statement are: "); //for statement for( num = 1; num <11; ++num) { //powering System.out.println(" 2 to the power of "+ num + " is: " + Math.pow(cons, num)); } |

All times are GMT +5.5. The time now is 04:18 AM. |