Блог пользователя adhansk68

Автор adhansk68, история, 4 года назад, По-английски

Calculate the largest number(in base 10) less than 1500000 which is a factorion number in base b. e.g. base=11, 26 is a factorion because 26 in base 11 is 24 and 2! + 4! = 26.

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

problem link?

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +6 Проголосовать: не нравится

    I don't have link it was asked previously in exam as told by my college senior

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится -6 Проголосовать: не нравится

      the first thing anyone does and should is to confirm whether this is a live contest problem or not , that's the only reason I asked you to provide link.

      since you do not have link yourself , there is no way to verify this , so unfortunately can not help.

      what can be done about it?

      since you asked the question yesterday , you can wait for like 9 more days (no contest i know which runs more than 10 days) , after that people can help (i have one solution in mind too).

      and apologies for not being able to help for now.

      I hope you understand.

      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится +8 Проголосовать: не нравится

        Can you explain it now? Or anyone who could figure it out ?

        • »
          »
          »
          »
          »
          3 года назад, # ^ |
          Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

          I had no idea why my contribution points were going down and thanks to this guy's comment now I know (since I commented 3 months ago I didn't knew there was something I need to answer).

          it is more of an implementation problem , the toughest part of it will be to convert a given number in base 10 to base b (so you can understand this is not that difficult problem).

          so here is how we can solve this problem.

          1. pre calculate factorials from 0 to 9 (because we only need factorial of digits).

          2. run a loop from 1500000 — 1 to 0 and check whether the current number is factorian number or not.

          3. if the current number is factorian number stop the loop and print current number.

          step 2 requires to check whether the given number is factorian number or not , for that you need to convert the current number from base 10 to base b after that you can easily check that.

          I am providing the code , you can check the implementation details there.

          code link : https://ideone.com/qe0RGm

          for base b = 11 , biggest factorial number less than the specified limit is 40472.

»
3 года назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

I recommand just do a brute force with precalculated factorial table