Result: Java Quiz: Show your java strength

17 views
Skip to first unread message

Kamlesh Paunikar

unread,
Sep 26, 2009, 6:22:32 AM9/26/09
to Code Gurukul


Using Recursion
============

If you are using recursion in your logic then it
will take too much time to process 2 power n also
recursion will use huge memory of stack.

Using Loop
=========
This will not take memory but it will be heavy
code for processing.

and therefore we need some fine code that should not take too much
time.

1. Code should be easy
2. Code should be fine
3. Should not take much memory.
4. Should process as early as possible.


Final Answer
==========
/**
*
* @author Kamlesh Paunikar
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int n=30;
int pow=1<<n;
System.out.println("Power ="+pow);
}

}
Reply all
Reply to author
Forward
0 new messages