Class PE0030

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Hashtable<LargeNumber,​LargeNumber> cache
      Stores the sums of the powered digits.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        PE0030()
      A simple constructor to set number and title.
      protected PE0030​(int num, java.lang.String tit)
      A simple base constructor to set the given Problem.number and Problem.title.
    • Method Summary

      Modifier and Type Method Description
      protected LargeNumber getDigitSum​(LargeNumber num)
      Calculates the sum of all digits of the given number.
      void prepare()
      Just the cache is initialized.
      java.lang.String solve()
      Beginning with 10 all numbers to 500.000 are tested, if the sum of its powered digits are equal to the number itself.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • cache

        protected java.util.Hashtable<LargeNumber,​LargeNumber> cache
        Stores the sums of the powered digits. As keys the sorted digits are used.
    • Constructor Detail

      • PE0030

        public PE0030()
        A simple constructor to set number and title.
      • PE0030

        protected PE0030​(int num,
                         java.lang.String tit)
        A simple base constructor to set the given Problem.number and Problem.title. In this special case it's needed for inheritance to PE0034.
        Parameters:
        num - - the number of this problem
        tit - - the title of this problem
    • Method Detail

      • solve

        public java.lang.String solve()
        Beginning with 10 all numbers to 500.000 are tested, if the sum of its powered digits are equal to the number itself. To speed up the search, the cache is used to reduce the power calculations.
        Returns:
        the sum of all found numbers that are equals to their powered digit sum