Generate some rough numbers
Clash 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
code-golf number-theory primes factoring
add a comment |Â
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
code-golf number-theory primes factoring
add a comment |Â
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
code-golf number-theory primes factoring
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
code-golf number-theory primes factoring
asked 1 hour ago


Addison Crump
8,24913279
8,24913279
add a comment |Â
add a comment |Â
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.
Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
– Addison Crump
47 mins ago
add a comment |Â
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
What doesall
do?
– Addison Crump
47 mins ago
@AddisonCrumpall
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
add a comment |Â
up vote
0
down vote
Jelly, 10 bytes
g³!¤Ịµâ´#1;
Try it online!
How it works
Coming soon.
add a comment |Â
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.
Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
– Addison Crump
47 mins ago
add a comment |Â
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.
Hmm, that assumption is probably verifiable, but an interesting problem nonetheless. I'll bounty for a proof.
– Addison Crump
47 mins ago
add a comment |Â
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.
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.
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
add a comment |Â
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
add a comment |Â
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
What doesall
do?
– Addison Crump
47 mins ago
@AddisonCrumpall
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
add a comment |Â
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
What doesall
do?
– Addison Crump
47 mins ago
@AddisonCrumpall
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
add a comment |Â
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
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
edited 30 mins ago
answered 55 mins ago
Jo King
18k24199
18k24199
What doesall
do?
– Addison Crump
47 mins ago
@AddisonCrumpall
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
add a comment |Â
What doesall
do?
– Addison Crump
47 mins ago
@AddisonCrumpall
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
add a comment |Â
up vote
0
down vote
Jelly, 10 bytes
g³!¤Ịµâ´#1;
Try it online!
How it works
Coming soon.
add a comment |Â
up vote
0
down vote
Jelly, 10 bytes
g³!¤Ịµâ´#1;
Try it online!
How it works
Coming soon.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Jelly, 10 bytes
g³!¤Ịµâ´#1;
Try it online!
How it works
Coming soon.
Jelly, 10 bytes
g³!¤Ịµâ´#1;
Try it online!
How it works
Coming soon.
answered 7 mins ago


Bubbler
4,559749
4,559749
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password