Linked Questions

150 votes
335 answers

Fibonacci function or sequence

The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first ...
C. K. Young's user avatar
  • 4,947
229 votes
65 answers

No A, just CAPS LOCK

What happens when the CapsLock key on your keyboard doesn't have a notch in it? "This hPPENS." The goal of this program is to consistently emulate keyboard misses where each A press is replaced with ...
Broadwell's user avatar
  • 1,841
87 votes
137 answers

Collatz Conjecture (OEIS A006577)

This is the Collatz Conjecture (OEIS A006577): Start with an integer n > 1. Repeat the following steps: If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. It is proven that ...
Doorknob's user avatar
  • 71.5k
53 votes
44 answers

Tips for golfing in Mathematica

What general tips do you have for golfing in Mathematica? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Mathematica (e.g. "remove ...
alephalpha's user avatar
48 votes
45 answers

The Ackermann function

The Ackermann function is notable for being the one of the simplest examples of a total, computable function that isn't primitive recursive. We will use the definition of \$A(m,n)\$ taking in two ...
algorithmshark's user avatar
43 votes
55 answers

Output the largest number with the fewest digits

Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits. The input list will not be in any particular order and may contain ...
Calvin's Hobbies's user avatar
28 votes
61 answers

Reversed Iota's

I didn't invent this challenge, but I find it very interesting to solve. For every input number, e.g.: 4 Generate a range from 1 to that number: ...
user avatar
31 votes
47 answers

Subtract the next numbers

Description Subtract the next P numbers from a N number. The next number of N is N + 1. Look at the examples to get what I mean. Examples: ...
Paul Schmitz's user avatar
  • 1,137
23 votes
36 answers

Smallest Bit Rotation

For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits. For example, when the given number is 177, whose binary representation is \$...
tsh's user avatar
  • 34.7k
34 votes
22 answers

Turn an Array into a Math Problem

Given a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where: A plus sign (+) is inserted between pairs of numbers that ...
Calvin's Hobbies's user avatar
29 votes
26 answers

Find the next 1-sparse binary number

A positive integer N is K-sparse if there are at least K 0s between any two consecutive 1s in its binary representation. So, the number 1010101 is 1-sparse whereas 101101 is not. Your task is to ...
articuno's user avatar
  • 391
26 votes
24 answers

Case Permutation

Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; ...
Poke's user avatar
  • 3,185
24 votes
26 answers

Jimmy these arrays down

My coworker, Jimmy is kinda new to C/C++. He's also kind of a slow learner. Now, to be fair, his code always compiles, but he has some really sloppy habits. For example, everybody knows that you can ...
DJMcMayhem's user avatar
  • 59.2k
21 votes
21 answers

Female and Male Sequences

This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison. Really looking forward to the answers! In his book "...
clismique's user avatar
  • 6,980
17 votes
27 answers

Order by Earliest Lower Digit

Given two strings of digits, determine which string, if any, has the earliest digit which is lower than the other string's digit at the same index. Do note that this differs from alphabetization, as ...
thejonymyster's user avatar

15 30 50 per page