Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication2;
- /**
- *
- * @author asrulsibaoel
- */
- public class JavaApplication2 {
- private int[] C = {101001};
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- JavaApplication2 coba = new JavaApplication2();
- System.out.println(coba.f2(6));
- }
- private int f2(int n) {
- int p = 1;
- int h = 0;
- for (int i = 0; i < n; i++) {
- h = h + (C[i] - 48) * p;
- p = p * 3;
- }
- return h;
- }
- }
- //return output -17219
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement