Skip to main content
Accidently inverted the first fraction
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

MathGolf, 4 3 bytes

⌂v▲ 

Pushes * with a probability of \$\frac{1}{4\text{,}294\text{,}967\text{,}295}\$\$\frac{4\text{,}294\text{,}967\text{,}294}{4\text{,}294\text{,}967\text{,}295}\$ (99.999999999767%) each iteration, and won't include the empty output (so will always output at least one *).

Don't try it online.

Previous 4 byter:

⌂v¶▼ 

Pushes * with a probability of \$\frac{837\text{,}973\text{,}946}{858\text{,}993\text{,}459}\$ (~97.55%) each iteration, and won't include the empty output (so will always output at least one *).

Try it online.

Explanation:

 ▲ # Do while falsey with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) # (only 0 is a falsey integer in MathGolf) # (after which the entire joined stack is output implicitly as result) 
 ▼ # Do while truthy with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) ¶ # Pop and check if this integer is a (positive) prime number # (after which the entire joined stack is output implicitly as result) 

The mentioned probability is basically the amount of non-prime numbers within the range \$[-2^{31},2^{31})\$ (which is \$4\text{,}189\text{,}869\text{,}730\$ according to WolframAlpha) as numerator and total amount of integers within the range \$[-2^{31},2^{31})\$ (basically \$2^{32}-1=4\text{,}294\text{,}967\text{,}295\$) as denominator (and then simplified by dividing both by their greatest common divisor \$5\$).

MathGolf, 4 3 bytes

⌂v▲ 

Pushes * with a probability of \$\frac{1}{4\text{,}294\text{,}967\text{,}295}\$ (99.999999999767%) each iteration, and won't include the empty output (so will always output at least one *).

Don't try it online.

Previous 4 byter:

⌂v¶▼ 

Pushes * with a probability of \$\frac{837\text{,}973\text{,}946}{858\text{,}993\text{,}459}\$ (~97.55%) each iteration, and won't include the empty output (so will always output at least one *).

Try it online.

Explanation:

 ▲ # Do while falsey with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) # (only 0 is a falsey integer in MathGolf) # (after which the entire joined stack is output implicitly as result) 
 ▼ # Do while truthy with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) ¶ # Pop and check if this integer is a (positive) prime number # (after which the entire joined stack is output implicitly as result) 

The mentioned probability is basically the amount of non-prime numbers within the range \$[-2^{31},2^{31})\$ (which is \$4\text{,}189\text{,}869\text{,}730\$ according to WolframAlpha) as numerator and total amount of integers within the range \$[-2^{31},2^{31})\$ (basically \$2^{32}-1=4\text{,}294\text{,}967\text{,}295\$) as denominator (and then simplified by dividing both by their greatest common divisor \$5\$).

MathGolf, 4 3 bytes

⌂v▲ 

Pushes * with a probability of \$\frac{4\text{,}294\text{,}967\text{,}294}{4\text{,}294\text{,}967\text{,}295}\$ (99.999999999767%) each iteration, and won't include the empty output (so will always output at least one *).

Don't try it online.

Previous 4 byter:

⌂v¶▼ 

Pushes * with a probability of \$\frac{837\text{,}973\text{,}946}{858\text{,}993\text{,}459}\$ (~97.55%) each iteration, and won't include the empty output (so will always output at least one *).

Try it online.

Explanation:

 ▲ # Do while falsey with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) # (only 0 is a falsey integer in MathGolf) # (after which the entire joined stack is output implicitly as result) 
 ▼ # Do while truthy with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) ¶ # Pop and check if this integer is a (positive) prime number # (after which the entire joined stack is output implicitly as result) 

The mentioned probability is basically the amount of non-prime numbers within the range \$[-2^{31},2^{31})\$ (which is \$4\text{,}189\text{,}869\text{,}730\$ according to WolframAlpha) as numerator and total amount of integers within the range \$[-2^{31},2^{31})\$ (basically \$2^{32}-1=4\text{,}294\text{,}967\text{,}295\$) as denominator (and then simplified by dividing both by their greatest common divisor \$5\$).

added 522 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

MathGolf, 4 4 3 bytes

⌂v▲ 

Pushes * with a probability of \$\frac{1}{4\text{,}294\text{,}967\text{,}295}\$ (99.999999999767%) each iteration, and won't include the empty output (so will always output at least one *).

Don't try it online.

Previous 4 byter:

⌂v¶▼ 

Pushes * with a probability of \$\frac{837\text{,}973\text{,}946}{858\text{,}993\text{,}459}\$ (~97.55%) each iteration, and won't include the empty output (so will always output at least a singleone *).

Try it online.

Explanation:

 ▲ # Do while falsey with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) # (only 0 is a falsey integer in MathGolf) # (after which the entire joined stack is output implicitly as result) 
 ▼ # Do while truthy with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) ¶ # Pop and check if this integer is a (positive) prime number # (after which the entire joined stack is output implicitly as result) 

The mentioned probability is basically the amount of non-prime numbers within the range \$[-2^{31},2^{31})\$ (which is \$4\text{,}189\text{,}869\text{,}730\$ according to WolframAlpha) as numerator and total amount of integers within the range \$[-2^{31},2^{31})\$ (basically \$2^{32}-1=4\text{,}294\text{,}967\text{,}295\$) as denominator (and then simplified by dividing both by their greatest common divisor \$5\$).

MathGolf, 4 bytes

⌂v¶▼ 

Pushes * with a probability of \$\frac{837\text{,}973\text{,}946}{858\text{,}993\text{,}459}\$ (~97.55%) each iteration, and won't include the empty output (so will always output at least a single *).

Try it online.

Explanation:

 ▼ # Do while truthy with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) ¶ # Pop and check if this integer is a (positive) prime number # (after which the entire joined stack is output implicitly as result) 

The mentioned probability is basically the amount of non-prime numbers within the range \$[-2^{31},2^{31})\$ (which is \$4\text{,}189\text{,}869\text{,}730\$ according to WolframAlpha) as numerator and total amount of integers within the range \$[-2^{31},2^{31})\$ (basically \$2^{32}-1=4\text{,}294\text{,}967\text{,}295\$) as denominator (and then simplified by dividing both by their greatest common divisor \$5\$).

MathGolf, 4 3 bytes

⌂v▲ 

Pushes * with a probability of \$\frac{1}{4\text{,}294\text{,}967\text{,}295}\$ (99.999999999767%) each iteration, and won't include the empty output (so will always output at least one *).

Don't try it online.

Previous 4 byter:

⌂v¶▼ 

Pushes * with a probability of \$\frac{837\text{,}973\text{,}946}{858\text{,}993\text{,}459}\$ (~97.55%) each iteration, and won't include the empty output (so will always output at least one *).

Try it online.

Explanation:

 ▲ # Do while falsey with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) # (only 0 is a falsey integer in MathGolf) # (after which the entire joined stack is output implicitly as result) 
 ▼ # Do while truthy with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) ¶ # Pop and check if this integer is a (positive) prime number # (after which the entire joined stack is output implicitly as result) 

The mentioned probability is basically the amount of non-prime numbers within the range \$[-2^{31},2^{31})\$ (which is \$4\text{,}189\text{,}869\text{,}730\$ according to WolframAlpha) as numerator and total amount of integers within the range \$[-2^{31},2^{31})\$ (basically \$2^{32}-1=4\text{,}294\text{,}967\text{,}295\$) as denominator (and then simplified by dividing both by their greatest common divisor \$5\$).

Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

MathGolf, 4 bytes

⌂v¶▼ 

Pushes * with a probability of \$\frac{837\text{,}973\text{,}946}{858\text{,}993\text{,}459}\$ (~97.55%) each iteration, and won't include the empty output (so will always output at least a single *).

Try it online.

Explanation:

 ▼ # Do while truthy with pop: ⌂ # Push character '*' v # Push a random integer in the range [-2³¹, 2³¹) ¶ # Pop and check if this integer is a (positive) prime number # (after which the entire joined stack is output implicitly as result) 

The mentioned probability is basically the amount of non-prime numbers within the range \$[-2^{31},2^{31})\$ (which is \$4\text{,}189\text{,}869\text{,}730\$ according to WolframAlpha) as numerator and total amount of integers within the range \$[-2^{31},2^{31})\$ (basically \$2^{32}-1=4\text{,}294\text{,}967\text{,}295\$) as denominator (and then simplified by dividing both by their greatest common divisor \$5\$).