Multiply and Divide

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












Given a value x find the smallest numerical value greater than y that is capable of being multiplied and divided by x while retaining all original digits.



  • The new numbers do not lose digits.

  • The new numbers do not gain digits.

For example:




Input: x = 2, y = 250000



  • Original: 285714

    • Division: 142857

    • Multiplication: 571428


This is true because 285714 is greater than y; then when divided by x results in 142857 and when multiplied by x results in 571428. In both tests all of the original digits from 285714 are present and no extra digits have been added.





The Rules




  • X has to be a value between 2 and 5.


  • X and Y are required to be whole numbers greater than zero.

  • The shortest code wins.


Good luck to you all!










share|improve this question























  • Are digits counted with multiplicity? I.e., if x=11 and y=10, is 11 the answer? (11/11=1 which has the same digits as 11, but not with multiplicity). Also, is it ok if new digits appear when multiplying by x, as long as all the original digits are present?
    – Delfad0r
    1 hour ago










  • No digits are gained nor lost; and this has to be true for multiplication and division. In the case of x = 11 and y = 10 then 11 is not the answer; 11/11 = 1 and 11 * 11 = 121. Thus digits are lost and gained.
    – PerpetualJ
    1 hour ago















up vote
4
down vote

favorite












Given a value x find the smallest numerical value greater than y that is capable of being multiplied and divided by x while retaining all original digits.



  • The new numbers do not lose digits.

  • The new numbers do not gain digits.

For example:




Input: x = 2, y = 250000



  • Original: 285714

    • Division: 142857

    • Multiplication: 571428


This is true because 285714 is greater than y; then when divided by x results in 142857 and when multiplied by x results in 571428. In both tests all of the original digits from 285714 are present and no extra digits have been added.





The Rules




  • X has to be a value between 2 and 5.


  • X and Y are required to be whole numbers greater than zero.

  • The shortest code wins.


Good luck to you all!










share|improve this question























  • Are digits counted with multiplicity? I.e., if x=11 and y=10, is 11 the answer? (11/11=1 which has the same digits as 11, but not with multiplicity). Also, is it ok if new digits appear when multiplying by x, as long as all the original digits are present?
    – Delfad0r
    1 hour ago










  • No digits are gained nor lost; and this has to be true for multiplication and division. In the case of x = 11 and y = 10 then 11 is not the answer; 11/11 = 1 and 11 * 11 = 121. Thus digits are lost and gained.
    – PerpetualJ
    1 hour ago













up vote
4
down vote

favorite









up vote
4
down vote

favorite











Given a value x find the smallest numerical value greater than y that is capable of being multiplied and divided by x while retaining all original digits.



  • The new numbers do not lose digits.

  • The new numbers do not gain digits.

For example:




Input: x = 2, y = 250000



  • Original: 285714

    • Division: 142857

    • Multiplication: 571428


This is true because 285714 is greater than y; then when divided by x results in 142857 and when multiplied by x results in 571428. In both tests all of the original digits from 285714 are present and no extra digits have been added.





The Rules




  • X has to be a value between 2 and 5.


  • X and Y are required to be whole numbers greater than zero.

  • The shortest code wins.


Good luck to you all!










share|improve this question















Given a value x find the smallest numerical value greater than y that is capable of being multiplied and divided by x while retaining all original digits.



  • The new numbers do not lose digits.

  • The new numbers do not gain digits.

For example:




Input: x = 2, y = 250000



  • Original: 285714

    • Division: 142857

    • Multiplication: 571428


This is true because 285714 is greater than y; then when divided by x results in 142857 and when multiplied by x results in 571428. In both tests all of the original digits from 285714 are present and no extra digits have been added.





The Rules




  • X has to be a value between 2 and 5.


  • X and Y are required to be whole numbers greater than zero.

  • The shortest code wins.


Good luck to you all!







code-golf number






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago

























asked 1 hour ago









PerpetualJ

1315




1315











  • Are digits counted with multiplicity? I.e., if x=11 and y=10, is 11 the answer? (11/11=1 which has the same digits as 11, but not with multiplicity). Also, is it ok if new digits appear when multiplying by x, as long as all the original digits are present?
    – Delfad0r
    1 hour ago










  • No digits are gained nor lost; and this has to be true for multiplication and division. In the case of x = 11 and y = 10 then 11 is not the answer; 11/11 = 1 and 11 * 11 = 121. Thus digits are lost and gained.
    – PerpetualJ
    1 hour ago

















  • Are digits counted with multiplicity? I.e., if x=11 and y=10, is 11 the answer? (11/11=1 which has the same digits as 11, but not with multiplicity). Also, is it ok if new digits appear when multiplying by x, as long as all the original digits are present?
    – Delfad0r
    1 hour ago










  • No digits are gained nor lost; and this has to be true for multiplication and division. In the case of x = 11 and y = 10 then 11 is not the answer; 11/11 = 1 and 11 * 11 = 121. Thus digits are lost and gained.
    – PerpetualJ
    1 hour ago
















Are digits counted with multiplicity? I.e., if x=11 and y=10, is 11 the answer? (11/11=1 which has the same digits as 11, but not with multiplicity). Also, is it ok if new digits appear when multiplying by x, as long as all the original digits are present?
– Delfad0r
1 hour ago




Are digits counted with multiplicity? I.e., if x=11 and y=10, is 11 the answer? (11/11=1 which has the same digits as 11, but not with multiplicity). Also, is it ok if new digits appear when multiplying by x, as long as all the original digits are present?
– Delfad0r
1 hour ago












No digits are gained nor lost; and this has to be true for multiplication and division. In the case of x = 11 and y = 10 then 11 is not the answer; 11/11 = 1 and 11 * 11 = 121. Thus digits are lost and gained.
– PerpetualJ
1 hour ago





No digits are gained nor lost; and this has to be true for multiplication and division. In the case of x = 11 and y = 10 then 11 is not the answer; 11/11 = 1 and 11 * 11 = 121. Thus digits are lost and gained.
– PerpetualJ
1 hour ago











5 Answers
5






active

oldest

votes

















up vote
2
down vote














Husk, 14 bytes



ḟ§¤=OoDd§¤+d*/


Try it online!



Explanation



ḟ§¤=O(Dd)§¤+d*/ -- example inputs: x=2 y=1
ḟ -- find first value greater than y where the following is true (example on 285714)
§ -- | fork
§ -- | | fork
/ -- | | | divide by x: 142857
-- | | and
* -- | | | multiply by y: 571428
-- | | then do the following with 142857 and 571428
-- | | | concatenate but first take
+ -- | | | | digits: [1,4,2,8,5,7] [5,7,1,4,2,8]
¤ d -- | | | : [1,4,2,8,5,7,5,7,1,4,2,8]
-- | and
d -- | | digits: [2,8,5,7,1,4]
D -- | | double: [2,8,5,7,1,4,2,8,5,7,1,4]
-- | then do the following with [2,8,5,7,1,4,2,8,5,7,1,4] and [1,4,2,8,5,7,5,7,1,4,2,8]
= -- | | are they equal
¤ O -- | | | when sorted: [1,1,2,2,4,4,5,5,7,7,8,8] [1,1,2,2,4,4,5,5,7,7,8,8]
-- | : truthy
-- : 285714





share|improve this answer






















  • I adjusted the value for y to get a closer starting point and the result was incorrect for x = 3, y = 25000000.
    – PerpetualJ
    1 hour ago











  • @PerpetualJ: If you know the result then you can simply adjust y, and this version should be slightly faster (only the type-checking though).
    – BMO
    1 hour ago










  • I've adjusted it after some thought and edited my first comment.
    – PerpetualJ
    1 hour ago










  • @PerpetualJ: I've fixed it: made an assumption about - which was wrong.
    – BMO
    53 mins ago










  • That produced a correct result! :) I'm curious; how do you understand what's going on there by the way?
    – PerpetualJ
    47 mins ago

















up vote
1
down vote














Perl 6, 56 bytes





->x,yfirst [eqv] map *.comb.Bag,$_,$_*x,$_/x,y^..*


Try it online!



Interesting alternative, computing n*xk for k=-1,0,1:



->x,yfirst [eqv] map ($_*x***).comb.Bag,^3-1,y^..*





share|improve this answer





























    up vote
    0
    down vote













    Japt, 22 bytes



    Pretty naïve solution over a few beers; I'm sure there's a better way.



    @[X*UX/U]®ìnÃe¶Xìn}a°V


    Try it






    share|improve this answer




















    • Unfortunately this produces an incorrect result when x = 3 and y = 25000.
      – PerpetualJ
      1 hour ago

















    up vote
    0
    down vote














    Clean, 92 bytes



    import StdEnv
    $n m=hd[i\i<-[m..],[_]<-[removeDup[sort[c\c<-:toString j]\j<-[i,i/n,i*n]]]]


    Try it online!



    Pretty simple. Explanation coming in a while.






    share|improve this answer



























      up vote
      0
      down vote














      Jelly, 12 bytes



      ×;÷;⁸DṢ€Eð1#


      A full program printing the result (as a dyadic link a list of length 1 is yielded).



      Try it online!



      How?



      ×;÷;⁸DṢ€Eð1# - Main link: y, x
      # - count up from n=y, finding the first...
      1 - ...1 match:
      ð - using the dyad -- i.e. f(n, x): e.g. 285714, 2
      × - multiply -> n×x 571428
      ÷ - divide -> n÷x 142857
      ; - concatenate -> [n×x,n÷x] [571428,142857]
      ⁸ - chain's left argument = n 285714
      ; - concatenate -> [n×x,n÷x,n] [571428,142857,285714]
      D - to decimal (vectorises) [[5,7,1,4,2,8],[1,4,2,8,5,7],[2,8,5,7,1,4]]
      Ṣ€ - sort €ach [[1,2,4,5,7,8],[1,2,4,5,7,8],[1,2,4,5,7,8]]
      E - all equal? 1


      Note that when the division is not exact the decimal instruction yields a fractional part

      e.g.: 1800÷3D -> [6,0,0]

      while 1801÷3D -> [6.0,0.0,0.33333333333337123]






      share|improve this answer






















        Your Answer




        StackExchange.ifUsing("editor", function ()
        return StackExchange.using("mathjaxEditing", function ()
        StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
        StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
        );
        );
        , "mathjax-editing");

        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "200"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













         

        draft saved


        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172958%2fmultiply-and-divide%23new-answer', 'question_page');

        );

        Post as a guest






























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        2
        down vote














        Husk, 14 bytes



        ḟ§¤=OoDd§¤+d*/


        Try it online!



        Explanation



        ḟ§¤=O(Dd)§¤+d*/ -- example inputs: x=2 y=1
        ḟ -- find first value greater than y where the following is true (example on 285714)
        § -- | fork
        § -- | | fork
        / -- | | | divide by x: 142857
        -- | | and
        * -- | | | multiply by y: 571428
        -- | | then do the following with 142857 and 571428
        -- | | | concatenate but first take
        + -- | | | | digits: [1,4,2,8,5,7] [5,7,1,4,2,8]
        ¤ d -- | | | : [1,4,2,8,5,7,5,7,1,4,2,8]
        -- | and
        d -- | | digits: [2,8,5,7,1,4]
        D -- | | double: [2,8,5,7,1,4,2,8,5,7,1,4]
        -- | then do the following with [2,8,5,7,1,4,2,8,5,7,1,4] and [1,4,2,8,5,7,5,7,1,4,2,8]
        = -- | | are they equal
        ¤ O -- | | | when sorted: [1,1,2,2,4,4,5,5,7,7,8,8] [1,1,2,2,4,4,5,5,7,7,8,8]
        -- | : truthy
        -- : 285714





        share|improve this answer






















        • I adjusted the value for y to get a closer starting point and the result was incorrect for x = 3, y = 25000000.
          – PerpetualJ
          1 hour ago











        • @PerpetualJ: If you know the result then you can simply adjust y, and this version should be slightly faster (only the type-checking though).
          – BMO
          1 hour ago










        • I've adjusted it after some thought and edited my first comment.
          – PerpetualJ
          1 hour ago










        • @PerpetualJ: I've fixed it: made an assumption about - which was wrong.
          – BMO
          53 mins ago










        • That produced a correct result! :) I'm curious; how do you understand what's going on there by the way?
          – PerpetualJ
          47 mins ago














        up vote
        2
        down vote














        Husk, 14 bytes



        ḟ§¤=OoDd§¤+d*/


        Try it online!



        Explanation



        ḟ§¤=O(Dd)§¤+d*/ -- example inputs: x=2 y=1
        ḟ -- find first value greater than y where the following is true (example on 285714)
        § -- | fork
        § -- | | fork
        / -- | | | divide by x: 142857
        -- | | and
        * -- | | | multiply by y: 571428
        -- | | then do the following with 142857 and 571428
        -- | | | concatenate but first take
        + -- | | | | digits: [1,4,2,8,5,7] [5,7,1,4,2,8]
        ¤ d -- | | | : [1,4,2,8,5,7,5,7,1,4,2,8]
        -- | and
        d -- | | digits: [2,8,5,7,1,4]
        D -- | | double: [2,8,5,7,1,4,2,8,5,7,1,4]
        -- | then do the following with [2,8,5,7,1,4,2,8,5,7,1,4] and [1,4,2,8,5,7,5,7,1,4,2,8]
        = -- | | are they equal
        ¤ O -- | | | when sorted: [1,1,2,2,4,4,5,5,7,7,8,8] [1,1,2,2,4,4,5,5,7,7,8,8]
        -- | : truthy
        -- : 285714





        share|improve this answer






















        • I adjusted the value for y to get a closer starting point and the result was incorrect for x = 3, y = 25000000.
          – PerpetualJ
          1 hour ago











        • @PerpetualJ: If you know the result then you can simply adjust y, and this version should be slightly faster (only the type-checking though).
          – BMO
          1 hour ago










        • I've adjusted it after some thought and edited my first comment.
          – PerpetualJ
          1 hour ago










        • @PerpetualJ: I've fixed it: made an assumption about - which was wrong.
          – BMO
          53 mins ago










        • That produced a correct result! :) I'm curious; how do you understand what's going on there by the way?
          – PerpetualJ
          47 mins ago












        up vote
        2
        down vote










        up vote
        2
        down vote










        Husk, 14 bytes



        ḟ§¤=OoDd§¤+d*/


        Try it online!



        Explanation



        ḟ§¤=O(Dd)§¤+d*/ -- example inputs: x=2 y=1
        ḟ -- find first value greater than y where the following is true (example on 285714)
        § -- | fork
        § -- | | fork
        / -- | | | divide by x: 142857
        -- | | and
        * -- | | | multiply by y: 571428
        -- | | then do the following with 142857 and 571428
        -- | | | concatenate but first take
        + -- | | | | digits: [1,4,2,8,5,7] [5,7,1,4,2,8]
        ¤ d -- | | | : [1,4,2,8,5,7,5,7,1,4,2,8]
        -- | and
        d -- | | digits: [2,8,5,7,1,4]
        D -- | | double: [2,8,5,7,1,4,2,8,5,7,1,4]
        -- | then do the following with [2,8,5,7,1,4,2,8,5,7,1,4] and [1,4,2,8,5,7,5,7,1,4,2,8]
        = -- | | are they equal
        ¤ O -- | | | when sorted: [1,1,2,2,4,4,5,5,7,7,8,8] [1,1,2,2,4,4,5,5,7,7,8,8]
        -- | : truthy
        -- : 285714





        share|improve this answer















        Husk, 14 bytes



        ḟ§¤=OoDd§¤+d*/


        Try it online!



        Explanation



        ḟ§¤=O(Dd)§¤+d*/ -- example inputs: x=2 y=1
        ḟ -- find first value greater than y where the following is true (example on 285714)
        § -- | fork
        § -- | | fork
        / -- | | | divide by x: 142857
        -- | | and
        * -- | | | multiply by y: 571428
        -- | | then do the following with 142857 and 571428
        -- | | | concatenate but first take
        + -- | | | | digits: [1,4,2,8,5,7] [5,7,1,4,2,8]
        ¤ d -- | | | : [1,4,2,8,5,7,5,7,1,4,2,8]
        -- | and
        d -- | | digits: [2,8,5,7,1,4]
        D -- | | double: [2,8,5,7,1,4,2,8,5,7,1,4]
        -- | then do the following with [2,8,5,7,1,4,2,8,5,7,1,4] and [1,4,2,8,5,7,5,7,1,4,2,8]
        = -- | | are they equal
        ¤ O -- | | | when sorted: [1,1,2,2,4,4,5,5,7,7,8,8] [1,1,2,2,4,4,5,5,7,7,8,8]
        -- | : truthy
        -- : 285714






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 42 mins ago

























        answered 1 hour ago









        BMO

        9,74411773




        9,74411773











        • I adjusted the value for y to get a closer starting point and the result was incorrect for x = 3, y = 25000000.
          – PerpetualJ
          1 hour ago











        • @PerpetualJ: If you know the result then you can simply adjust y, and this version should be slightly faster (only the type-checking though).
          – BMO
          1 hour ago










        • I've adjusted it after some thought and edited my first comment.
          – PerpetualJ
          1 hour ago










        • @PerpetualJ: I've fixed it: made an assumption about - which was wrong.
          – BMO
          53 mins ago










        • That produced a correct result! :) I'm curious; how do you understand what's going on there by the way?
          – PerpetualJ
          47 mins ago
















        • I adjusted the value for y to get a closer starting point and the result was incorrect for x = 3, y = 25000000.
          – PerpetualJ
          1 hour ago











        • @PerpetualJ: If you know the result then you can simply adjust y, and this version should be slightly faster (only the type-checking though).
          – BMO
          1 hour ago










        • I've adjusted it after some thought and edited my first comment.
          – PerpetualJ
          1 hour ago










        • @PerpetualJ: I've fixed it: made an assumption about - which was wrong.
          – BMO
          53 mins ago










        • That produced a correct result! :) I'm curious; how do you understand what's going on there by the way?
          – PerpetualJ
          47 mins ago















        I adjusted the value for y to get a closer starting point and the result was incorrect for x = 3, y = 25000000.
        – PerpetualJ
        1 hour ago





        I adjusted the value for y to get a closer starting point and the result was incorrect for x = 3, y = 25000000.
        – PerpetualJ
        1 hour ago













        @PerpetualJ: If you know the result then you can simply adjust y, and this version should be slightly faster (only the type-checking though).
        – BMO
        1 hour ago




        @PerpetualJ: If you know the result then you can simply adjust y, and this version should be slightly faster (only the type-checking though).
        – BMO
        1 hour ago












        I've adjusted it after some thought and edited my first comment.
        – PerpetualJ
        1 hour ago




        I've adjusted it after some thought and edited my first comment.
        – PerpetualJ
        1 hour ago












        @PerpetualJ: I've fixed it: made an assumption about - which was wrong.
        – BMO
        53 mins ago




        @PerpetualJ: I've fixed it: made an assumption about - which was wrong.
        – BMO
        53 mins ago












        That produced a correct result! :) I'm curious; how do you understand what's going on there by the way?
        – PerpetualJ
        47 mins ago




        That produced a correct result! :) I'm curious; how do you understand what's going on there by the way?
        – PerpetualJ
        47 mins ago










        up vote
        1
        down vote














        Perl 6, 56 bytes





        ->x,yfirst [eqv] map *.comb.Bag,$_,$_*x,$_/x,y^..*


        Try it online!



        Interesting alternative, computing n*xk for k=-1,0,1:



        ->x,yfirst [eqv] map ($_*x***).comb.Bag,^3-1,y^..*





        share|improve this answer


























          up vote
          1
          down vote














          Perl 6, 56 bytes





          ->x,yfirst [eqv] map *.comb.Bag,$_,$_*x,$_/x,y^..*


          Try it online!



          Interesting alternative, computing n*xk for k=-1,0,1:



          ->x,yfirst [eqv] map ($_*x***).comb.Bag,^3-1,y^..*





          share|improve this answer
























            up vote
            1
            down vote










            up vote
            1
            down vote










            Perl 6, 56 bytes





            ->x,yfirst [eqv] map *.comb.Bag,$_,$_*x,$_/x,y^..*


            Try it online!



            Interesting alternative, computing n*xk for k=-1,0,1:



            ->x,yfirst [eqv] map ($_*x***).comb.Bag,^3-1,y^..*





            share|improve this answer















            Perl 6, 56 bytes





            ->x,yfirst [eqv] map *.comb.Bag,$_,$_*x,$_/x,y^..*


            Try it online!



            Interesting alternative, computing n*xk for k=-1,0,1:



            ->x,yfirst [eqv] map ($_*x***).comb.Bag,^3-1,y^..*






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 10 mins ago

























            answered 28 mins ago









            nwellnhof

            3,833715




            3,833715




















                up vote
                0
                down vote













                Japt, 22 bytes



                Pretty naïve solution over a few beers; I'm sure there's a better way.



                @[X*UX/U]®ìnÃe¶Xìn}a°V


                Try it






                share|improve this answer




















                • Unfortunately this produces an incorrect result when x = 3 and y = 25000.
                  – PerpetualJ
                  1 hour ago














                up vote
                0
                down vote













                Japt, 22 bytes



                Pretty naïve solution over a few beers; I'm sure there's a better way.



                @[X*UX/U]®ìnÃe¶Xìn}a°V


                Try it






                share|improve this answer




















                • Unfortunately this produces an incorrect result when x = 3 and y = 25000.
                  – PerpetualJ
                  1 hour ago












                up vote
                0
                down vote










                up vote
                0
                down vote









                Japt, 22 bytes



                Pretty naïve solution over a few beers; I'm sure there's a better way.



                @[X*UX/U]®ìnÃe¶Xìn}a°V


                Try it






                share|improve this answer












                Japt, 22 bytes



                Pretty naïve solution over a few beers; I'm sure there's a better way.



                @[X*UX/U]®ìnÃe¶Xìn}a°V


                Try it







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                Shaggy

                16.9k21661




                16.9k21661











                • Unfortunately this produces an incorrect result when x = 3 and y = 25000.
                  – PerpetualJ
                  1 hour ago
















                • Unfortunately this produces an incorrect result when x = 3 and y = 25000.
                  – PerpetualJ
                  1 hour ago















                Unfortunately this produces an incorrect result when x = 3 and y = 25000.
                – PerpetualJ
                1 hour ago




                Unfortunately this produces an incorrect result when x = 3 and y = 25000.
                – PerpetualJ
                1 hour ago










                up vote
                0
                down vote














                Clean, 92 bytes



                import StdEnv
                $n m=hd[i\i<-[m..],[_]<-[removeDup[sort[c\c<-:toString j]\j<-[i,i/n,i*n]]]]


                Try it online!



                Pretty simple. Explanation coming in a while.






                share|improve this answer
























                  up vote
                  0
                  down vote














                  Clean, 92 bytes



                  import StdEnv
                  $n m=hd[i\i<-[m..],[_]<-[removeDup[sort[c\c<-:toString j]\j<-[i,i/n,i*n]]]]


                  Try it online!



                  Pretty simple. Explanation coming in a while.






                  share|improve this answer






















                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote










                    Clean, 92 bytes



                    import StdEnv
                    $n m=hd[i\i<-[m..],[_]<-[removeDup[sort[c\c<-:toString j]\j<-[i,i/n,i*n]]]]


                    Try it online!



                    Pretty simple. Explanation coming in a while.






                    share|improve this answer













                    Clean, 92 bytes



                    import StdEnv
                    $n m=hd[i\i<-[m..],[_]<-[removeDup[sort[c\c<-:toString j]\j<-[i,i/n,i*n]]]]


                    Try it online!



                    Pretty simple. Explanation coming in a while.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 29 mins ago









                    Οurous

                    5,33311031




                    5,33311031




















                        up vote
                        0
                        down vote














                        Jelly, 12 bytes



                        ×;÷;⁸DṢ€Eð1#


                        A full program printing the result (as a dyadic link a list of length 1 is yielded).



                        Try it online!



                        How?



                        ×;÷;⁸DṢ€Eð1# - Main link: y, x
                        # - count up from n=y, finding the first...
                        1 - ...1 match:
                        ð - using the dyad -- i.e. f(n, x): e.g. 285714, 2
                        × - multiply -> n×x 571428
                        ÷ - divide -> n÷x 142857
                        ; - concatenate -> [n×x,n÷x] [571428,142857]
                        ⁸ - chain's left argument = n 285714
                        ; - concatenate -> [n×x,n÷x,n] [571428,142857,285714]
                        D - to decimal (vectorises) [[5,7,1,4,2,8],[1,4,2,8,5,7],[2,8,5,7,1,4]]
                        Ṣ€ - sort €ach [[1,2,4,5,7,8],[1,2,4,5,7,8],[1,2,4,5,7,8]]
                        E - all equal? 1


                        Note that when the division is not exact the decimal instruction yields a fractional part

                        e.g.: 1800÷3D -> [6,0,0]

                        while 1801÷3D -> [6.0,0.0,0.33333333333337123]






                        share|improve this answer


























                          up vote
                          0
                          down vote














                          Jelly, 12 bytes



                          ×;÷;⁸DṢ€Eð1#


                          A full program printing the result (as a dyadic link a list of length 1 is yielded).



                          Try it online!



                          How?



                          ×;÷;⁸DṢ€Eð1# - Main link: y, x
                          # - count up from n=y, finding the first...
                          1 - ...1 match:
                          ð - using the dyad -- i.e. f(n, x): e.g. 285714, 2
                          × - multiply -> n×x 571428
                          ÷ - divide -> n÷x 142857
                          ; - concatenate -> [n×x,n÷x] [571428,142857]
                          ⁸ - chain's left argument = n 285714
                          ; - concatenate -> [n×x,n÷x,n] [571428,142857,285714]
                          D - to decimal (vectorises) [[5,7,1,4,2,8],[1,4,2,8,5,7],[2,8,5,7,1,4]]
                          Ṣ€ - sort €ach [[1,2,4,5,7,8],[1,2,4,5,7,8],[1,2,4,5,7,8]]
                          E - all equal? 1


                          Note that when the division is not exact the decimal instruction yields a fractional part

                          e.g.: 1800÷3D -> [6,0,0]

                          while 1801÷3D -> [6.0,0.0,0.33333333333337123]






                          share|improve this answer
























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote










                            Jelly, 12 bytes



                            ×;÷;⁸DṢ€Eð1#


                            A full program printing the result (as a dyadic link a list of length 1 is yielded).



                            Try it online!



                            How?



                            ×;÷;⁸DṢ€Eð1# - Main link: y, x
                            # - count up from n=y, finding the first...
                            1 - ...1 match:
                            ð - using the dyad -- i.e. f(n, x): e.g. 285714, 2
                            × - multiply -> n×x 571428
                            ÷ - divide -> n÷x 142857
                            ; - concatenate -> [n×x,n÷x] [571428,142857]
                            ⁸ - chain's left argument = n 285714
                            ; - concatenate -> [n×x,n÷x,n] [571428,142857,285714]
                            D - to decimal (vectorises) [[5,7,1,4,2,8],[1,4,2,8,5,7],[2,8,5,7,1,4]]
                            Ṣ€ - sort €ach [[1,2,4,5,7,8],[1,2,4,5,7,8],[1,2,4,5,7,8]]
                            E - all equal? 1


                            Note that when the division is not exact the decimal instruction yields a fractional part

                            e.g.: 1800÷3D -> [6,0,0]

                            while 1801÷3D -> [6.0,0.0,0.33333333333337123]






                            share|improve this answer















                            Jelly, 12 bytes



                            ×;÷;⁸DṢ€Eð1#


                            A full program printing the result (as a dyadic link a list of length 1 is yielded).



                            Try it online!



                            How?



                            ×;÷;⁸DṢ€Eð1# - Main link: y, x
                            # - count up from n=y, finding the first...
                            1 - ...1 match:
                            ð - using the dyad -- i.e. f(n, x): e.g. 285714, 2
                            × - multiply -> n×x 571428
                            ÷ - divide -> n÷x 142857
                            ; - concatenate -> [n×x,n÷x] [571428,142857]
                            ⁸ - chain's left argument = n 285714
                            ; - concatenate -> [n×x,n÷x,n] [571428,142857,285714]
                            D - to decimal (vectorises) [[5,7,1,4,2,8],[1,4,2,8,5,7],[2,8,5,7,1,4]]
                            Ṣ€ - sort €ach [[1,2,4,5,7,8],[1,2,4,5,7,8],[1,2,4,5,7,8]]
                            E - all equal? 1


                            Note that when the division is not exact the decimal instruction yields a fractional part

                            e.g.: 1800÷3D -> [6,0,0]

                            while 1801÷3D -> [6.0,0.0,0.33333333333337123]







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 17 mins ago

























                            answered 36 mins ago









                            Jonathan Allan

                            48.6k534159




                            48.6k534159



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172958%2fmultiply-and-divide%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Comments

                                Popular posts from this blog

                                Long meetings (6-7 hours a day): Being “babysat” by supervisor

                                What does second last employer means? [closed]

                                One-line joke