Generate some rough numbers

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











up vote
3
down vote

favorite












Background



A number n can be described as B-rough if all of the prime factors of n strictly exceed B.



The Challenge



Given two positive integers B and k, output the first k B-rough numbers.



Examples



Let f(B, k) be a function which returns the set containing the first k B-rough numbers.



> f(1, 10)
1, 2, 3, 4, 5, 6, 7, 8, 9, 10

> f(2, 5)
1, 3, 5, 7, 9

> f(10, 14)
1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59









share|improve this question

























    up vote
    3
    down vote

    favorite












    Background



    A number n can be described as B-rough if all of the prime factors of n strictly exceed B.



    The Challenge



    Given two positive integers B and k, output the first k B-rough numbers.



    Examples



    Let f(B, k) be a function which returns the set containing the first k B-rough numbers.



    > f(1, 10)
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10

    > f(2, 5)
    1, 3, 5, 7, 9

    > f(10, 14)
    1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59









    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      Background



      A number n can be described as B-rough if all of the prime factors of n strictly exceed B.



      The Challenge



      Given two positive integers B and k, output the first k B-rough numbers.



      Examples



      Let f(B, k) be a function which returns the set containing the first k B-rough numbers.



      > f(1, 10)
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10

      > f(2, 5)
      1, 3, 5, 7, 9

      > f(10, 14)
      1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59









      share|improve this question













      Background



      A number n can be described as B-rough if all of the prime factors of n strictly exceed B.



      The Challenge



      Given two positive integers B and k, output the first k B-rough numbers.



      Examples



      Let f(B, k) be a function which returns the set containing the first k B-rough numbers.



      > f(1, 10)
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10

      > f(2, 5)
      1, 3, 5, 7, 9

      > f(10, 14)
      1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59






      code-golf number-theory primes factoring






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Addison Crump

      8,24913279




      8,24913279




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          2
          down vote














          Python 3, 80 bytes





          lambda B,k:[*filter(lambda i:all(i%j for j in range(2,B+1)),range(1,-~B*k))][:k]


          Try it online!



          This assumes that the k'th B-rough number will never exceed $B * k$, which I don't know how to prove, but seems like a fairly safe assumption (and I can't find any counterexamples).



          Alternate solution:




          Python 2, 83 bytes





          B,k=input()
          l,i=,1
          while k:
          if all(i%j for j in range(2,B+1)):print i;k-=1
          i+=1


          Try it online!



          This solution does not make the above solution. And is much more efficient.






          share|improve this answer




















          • Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
            – Addison Crump
            47 mins ago

















          up vote
          1
          down vote














          Perl 6, 35 bytes





          (grep (*X%2..$^b).all,1..*)[^$^k]


          Try it online!



          An anonymous code block that takes two integers and returns a list of integers.



          Explanation



           # Anonymous code block
          grep ,1..* # Filter from the positive integers
          * # Is the number
          % # Not divisible by
          ( X ).all # All the numbers
          2..$^b # From 2 to b
          ( )[^$^k] # And take the first k numbers





          share|improve this answer






















          • What does all do?
            – Addison Crump
            47 mins ago










          • @AddisonCrump all checks if all the elements in the list are truthy. I will be adding an explanation for the whole thing shortly
            – Jo King
            44 mins ago

















          up vote
          0
          down vote














          Jelly, 10 bytes



          g³!¤Ịµ⁴#1;


          Try it online!



          How it works



          Coming soon.





          share




















            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: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            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%2f175158%2fgenerate-some-rough-numbers%23new-answer', 'question_page');

            );

            Post as a guest






























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote














            Python 3, 80 bytes





            lambda B,k:[*filter(lambda i:all(i%j for j in range(2,B+1)),range(1,-~B*k))][:k]


            Try it online!



            This assumes that the k'th B-rough number will never exceed $B * k$, which I don't know how to prove, but seems like a fairly safe assumption (and I can't find any counterexamples).



            Alternate solution:




            Python 2, 83 bytes





            B,k=input()
            l,i=,1
            while k:
            if all(i%j for j in range(2,B+1)):print i;k-=1
            i+=1


            Try it online!



            This solution does not make the above solution. And is much more efficient.






            share|improve this answer




















            • Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
              – Addison Crump
              47 mins ago














            up vote
            2
            down vote














            Python 3, 80 bytes





            lambda B,k:[*filter(lambda i:all(i%j for j in range(2,B+1)),range(1,-~B*k))][:k]


            Try it online!



            This assumes that the k'th B-rough number will never exceed $B * k$, which I don't know how to prove, but seems like a fairly safe assumption (and I can't find any counterexamples).



            Alternate solution:




            Python 2, 83 bytes





            B,k=input()
            l,i=,1
            while k:
            if all(i%j for j in range(2,B+1)):print i;k-=1
            i+=1


            Try it online!



            This solution does not make the above solution. And is much more efficient.






            share|improve this answer




















            • Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
              – Addison Crump
              47 mins ago












            up vote
            2
            down vote










            up vote
            2
            down vote










            Python 3, 80 bytes





            lambda B,k:[*filter(lambda i:all(i%j for j in range(2,B+1)),range(1,-~B*k))][:k]


            Try it online!



            This assumes that the k'th B-rough number will never exceed $B * k$, which I don't know how to prove, but seems like a fairly safe assumption (and I can't find any counterexamples).



            Alternate solution:




            Python 2, 83 bytes





            B,k=input()
            l,i=,1
            while k:
            if all(i%j for j in range(2,B+1)):print i;k-=1
            i+=1


            Try it online!



            This solution does not make the above solution. And is much more efficient.






            share|improve this answer













            Python 3, 80 bytes





            lambda B,k:[*filter(lambda i:all(i%j for j in range(2,B+1)),range(1,-~B*k))][:k]


            Try it online!



            This assumes that the k'th B-rough number will never exceed $B * k$, which I don't know how to prove, but seems like a fairly safe assumption (and I can't find any counterexamples).



            Alternate solution:




            Python 2, 83 bytes





            B,k=input()
            l,i=,1
            while k:
            if all(i%j for j in range(2,B+1)):print i;k-=1
            i+=1


            Try it online!



            This solution does not make the above solution. And is much more efficient.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 53 mins ago









            DJMcMayhem♦

            40.5k11143307




            40.5k11143307











            • Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
              – Addison Crump
              47 mins ago
















            • Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
              – Addison Crump
              47 mins ago















            Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
            – Addison Crump
            47 mins ago




            Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
            – Addison Crump
            47 mins ago










            up vote
            1
            down vote














            Perl 6, 35 bytes





            (grep (*X%2..$^b).all,1..*)[^$^k]


            Try it online!



            An anonymous code block that takes two integers and returns a list of integers.



            Explanation



             # Anonymous code block
            grep ,1..* # Filter from the positive integers
            * # Is the number
            % # Not divisible by
            ( X ).all # All the numbers
            2..$^b # From 2 to b
            ( )[^$^k] # And take the first k numbers





            share|improve this answer






















            • What does all do?
              – Addison Crump
              47 mins ago










            • @AddisonCrump all checks if all the elements in the list are truthy. I will be adding an explanation for the whole thing shortly
              – Jo King
              44 mins ago














            up vote
            1
            down vote














            Perl 6, 35 bytes





            (grep (*X%2..$^b).all,1..*)[^$^k]


            Try it online!



            An anonymous code block that takes two integers and returns a list of integers.



            Explanation



             # Anonymous code block
            grep ,1..* # Filter from the positive integers
            * # Is the number
            % # Not divisible by
            ( X ).all # All the numbers
            2..$^b # From 2 to b
            ( )[^$^k] # And take the first k numbers





            share|improve this answer






















            • What does all do?
              – Addison Crump
              47 mins ago










            • @AddisonCrump all checks if all the elements in the list are truthy. I will be adding an explanation for the whole thing shortly
              – Jo King
              44 mins ago












            up vote
            1
            down vote










            up vote
            1
            down vote










            Perl 6, 35 bytes





            (grep (*X%2..$^b).all,1..*)[^$^k]


            Try it online!



            An anonymous code block that takes two integers and returns a list of integers.



            Explanation



             # Anonymous code block
            grep ,1..* # Filter from the positive integers
            * # Is the number
            % # Not divisible by
            ( X ).all # All the numbers
            2..$^b # From 2 to b
            ( )[^$^k] # And take the first k numbers





            share|improve this answer















            Perl 6, 35 bytes





            (grep (*X%2..$^b).all,1..*)[^$^k]


            Try it online!



            An anonymous code block that takes two integers and returns a list of integers.



            Explanation



             # Anonymous code block
            grep ,1..* # Filter from the positive integers
            * # Is the number
            % # Not divisible by
            ( X ).all # All the numbers
            2..$^b # From 2 to b
            ( )[^$^k] # And take the first k numbers






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 30 mins ago

























            answered 55 mins ago









            Jo King

            18k24199




            18k24199











            • What does all do?
              – Addison Crump
              47 mins ago










            • @AddisonCrump all checks if all the elements in the list are truthy. I will be adding an explanation for the whole thing shortly
              – Jo King
              44 mins ago
















            • What does all do?
              – Addison Crump
              47 mins ago










            • @AddisonCrump all checks if all the elements in the list are truthy. I will be adding an explanation for the whole thing shortly
              – Jo King
              44 mins ago















            What does all do?
            – Addison Crump
            47 mins ago




            What does all do?
            – Addison Crump
            47 mins ago












            @AddisonCrump all checks if all the elements in the list are truthy. I will be adding an explanation for the whole thing shortly
            – Jo King
            44 mins ago




            @AddisonCrump all checks if all the elements in the list are truthy. I will be adding an explanation for the whole thing shortly
            – Jo King
            44 mins ago










            up vote
            0
            down vote














            Jelly, 10 bytes



            g³!¤Ịµ⁴#1;


            Try it online!



            How it works



            Coming soon.





            share
























              up vote
              0
              down vote














              Jelly, 10 bytes



              g³!¤Ịµ⁴#1;


              Try it online!



              How it works



              Coming soon.





              share






















                up vote
                0
                down vote










                up vote
                0
                down vote










                Jelly, 10 bytes



                g³!¤Ịµ⁴#1;


                Try it online!



                How it works



                Coming soon.





                share













                Jelly, 10 bytes



                g³!¤Ịµ⁴#1;


                Try it online!



                How it works



                Coming soon.






                share











                share


                share










                answered 7 mins ago









                Bubbler

                4,559749




                4,559749



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175158%2fgenerate-some-rough-numbers%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery