Advertisement
mcnealk

Exercise #2

Oct 1st, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. import java.util.*;
  2. public class ExerciseTwo
  3. {
  4. public static void main (String[] args)
  5. {
  6. printPowersof2(3);
  7. }
  8. public static void printPowersof2(int max)
  9. {
  10. for (int i =0; i<=max; i++) //exponent
  11. {
  12. double ans=Math.pow(2,i);
  13. System.out.print(ans);
  14. }
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement