• + 0 comments

    JAVA 8

        public static int utopianTree(int n) {
        int count=1;
         for(int i=0; i<n; i++) {
             if(count%2==1) {
                 count*=2;
             }
             else {
                 count++;
             }
         }
         return count;
    }