Linked Questions

-2
votes
6answers
316 views

Double Factorial [duplicate]

Challenge The objective is simple, in the shortest amount of bytes, write a function or program that takes a number and prints its double factorial. The input must be taken from stdin or a function ...
137
votes
50answers
23k views

Tips for golfing in C

What general tips do you have for golfing in C? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C (e.g. "remove comments" is not an ...
34
votes
35answers
5k views

Repeated! Factorials!

Not to be confused with Find the factorial! Introduction The factorial of an integer n can be calculated by $$n!=n\times(n-1)\times(n-2)\times(...)\times2\times1$$...
33
votes
24answers
3k views

Factorials and never ending cycles!

As you may know it, the factorial of a positive integer n is the product of all the positive integers which are equal or smaller to ...
24
votes
24answers
2k views

Deranged !Combinatorics: Compute the Subfactorial

The subfactorial or rencontres numbers (A000166) are a sequence of numbers similar to the factorial numbers which show up in the combinatorics of permutations. In particular the nth subfactorial !n ...
22
votes
28answers
3k views

Last non-zero digit of n!

Given an integer 1 ≤ N ≤ 1,000,000 as input, output the last non-zero digit of N!, where ! is the factorial (the product of all numbers from 1 to N, inclusive). This is OEIS sequence A008904. Your ...
32
votes
14answers
2k views

Array Escape - get out of there

One day you awake only to find yourself caught in an array. You try to just walk out of there, taking one index at the time, but it seems there are other rules: The array is completely filled with ...
11
votes
26answers
2k views

Mathematical Combination

Write a program that takes an input such as: n,k which then computes: and then prints the result. A numerical example: Input: ...
14
votes
19answers
3k views

How much candy can you eat?

Credit to Geobits in TNB for the idea A post without sufficient detail recently posited an interesting game: 2 children sit in front of an array of candy. Each piece of candy is numbered 1 to ...
14
votes
15answers
1k views

Am I a Pillai prime?

A Pillai prime is a prime number \$p\$ for which there exists some positive \$m\$ such that \$(m! + 1) \equiv 0 \:(\text{mod } p)\$ and \$p \not\equiv 1\:(\text{mod }m)\$. In other words, an ...
24
votes
11answers
994 views

Tips for golfing in Swift

What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help ...
14
votes
14answers
662 views

Verify Wolstenholme's theorem

Definition Wolstenholme's theorem states that: where a and b are positive integers and p ...
34
votes
6answers
4k views

Python workarounds for assignment in lambda

This is a tips question for golfing in Python. In Python golfing, it's common for a submission to be a function defined as a lambda. For example, ...
31
votes
3answers
657 views

Build a golfing language with me

A lot of PPCG users helped with the creation of this challenge, both in chat and the Sandbox, specifically Martin Ender, AdmBorkBork, Emigna and user202729 Our community has found it necessary to ...