Double Exponential Function

For positive integer x x less than 99 99 , let f ( x ) = ( x x x ) m o d 100 \large f(x) = \left ( x^{x^x} \right ) \bmod {100} . What value of x x yields the largest f ( x ) f(x) ?


The answer is 77.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Thaddeus Abiy
May 7, 2014

Modular Exponentiation .

Two lines of code will do the trick here.

1
2
Dict={pow(x,pow(x,x,100),100):x for x in range(99)}
print Dict[max(Dict)]

Kenny Lau
Aug 29, 2014

Java:

public class brilliant{
    public static void main(String args[]){
        int max=-1,res=0;
        for(int i=0;i<99;i++){
            int exp = pow(i,pow(i,i,40),100);
            if(exp>max){
                max = exp;
                res = i;
            }
        }
        System.out.println(res);
    }
    private static int pow(int a,int b,int mod){
        int res = 1;
        for(int i=0;i<b;i++){
            res *= a;
            res %= mod;
        }
        return res;
    }
}
Aditya Sriram
Apr 15, 2014

I wrote this Java program for this:

public class Double_Exponential {

public static int f(int a, int b)
{
    int pro=a;
    for(int i=0;i<=b;i++)
    {
        pro = pro*b;
        pro = pro%100;
    }

    return f2(pro,b);
}
public static int f2(int pro, int b)
{
    for(int i=0;i<=b;i++)
    {
        pro = pro*b;
        pro = pro%100;
    }
    return pro;
}

public static void main(String []rgs)
{
    int l=1;
    for(int i = 1;i<99;i++)
    {
        if(f(i,i)>=f(l,l))
            l=i;
    }

    System.out.println("Answer is "+l);
}

}

And the output was "Answer is 77"

Basically, I figured that since only the last 2 digits matter, only the last 2 digits are required for each multiplication. Some of the stuff (like taking pro = a instead of using a) might be unnecessary but I tried a different method earlier for which that was required and was too lazy to make those changes :P

Aditya Sriram - 7 years, 1 month ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...