Linked Questions

14 votes
28 answers

Am I a Sophie Germain prime? [duplicate]

A Sophie Germain Prime is a prime number P such that 2P+1 is prime as well. Given a prime number as input, your task is to determine whether it is a Sophie Germain Prime. Standard Input/Output rules ...
Mr. Xcoder's user avatar
  • 42.4k
9 votes
20 answers

Prime numbers between n and 2n [duplicate]

Bertrand's postulate states that there is always at least 1 prime number between n and 2n for all n greater than 1. Challenge Your task is to take a positive integer n greater than 1 and find all of ...
buttercrab's user avatar
6 votes
15 answers

Check If my String is Prime [duplicate]

We define a prime character as a character that has a prime ASCII value. We define a prime string as a String that only contains prime characters. Given a String that only contains printable ASCII, ...
Mr. Xcoder's user avatar
  • 42.4k
-2 votes
6 answers

Primes, as efficiently inefficient as possible [duplicate]

Write a program that tests if a number n is prime by checking that none of the integers between 2 and ...
Arcturus's user avatar
  • 7,387
-4 votes
5 answers

Prime decimal representations of prime binary numbers [duplicate]

Problem Statement: Consider a number n in base-10. Find the smallest base-10 integer i greater than ...
user192361237's user avatar
522 votes
985 answers

"Hello, World!"

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
Martin Ender's user avatar
244 votes
455 answers

Golf you a quine for great good!

Using your language of choice, golf a quine. A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output. No cheating -- that means ...
Rafe Kettler's user avatar
  • 2,717
145 votes
570 answers

Shortest infinite loop producing no output

Your task is to create the shortest infinite loop! The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code ...
user41805's user avatar
  • 13.1k
173 votes
495 answers

Implement a Truth-Machine

A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does: Gets a ...
a spaghetto's user avatar
  • 11.2k
196 votes
416 answers

1, 2, Fizz, 4, Buzz

Introduction In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
Beta Decay's user avatar
  • 23.4k
79 votes
261 answers

Is this even or odd?

Note: There is not been a vanilla parity test challenge yet (There is a C/C++ one but that disallows the ability to use languages other than C/C++, and other non-vanilla ones are mostly closed too), ...
Matthew Roh's user avatar
  • 5,347
81 votes
94 answers

Golf all the 16 logic gates with 2 inputs and 1 output!

For example, the gate A and B is a logic gate with 2 inputs and 1 output. There are exactly 16 of them, because: each logic gate takes two inputs, which can be ...
Leaky Nun's user avatar
  • 49.8k
65 votes
115 answers

List of primes under a million

This is my first code golf question, and a very simple one at that, so I apologise in advance if I may have broken any community guidelines. The task is to print out, in ascending order, all of the ...
Delan Azabani's user avatar
106 votes
39 answers

Tips for golfing in Java

Are there any useful shortcuts that can be used in Java? As shown below, import already adds at least 17 characters to a program. ...
user avatar
43 votes
116 answers

Divisibility test

Task Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd. You ...
Leaky Nun's user avatar
  • 49.8k

15 30 50 per page
2 3 4 5 6