Questions tagged [pi]

This tag is for challenges involving the mathematical constant pi, the ratio of a circle's circumference to its diameter.

Filter by
Sorted by
Tagged with
13 votes
11 answers
5k views

Print 100 digits of π

Your challenge is to print any 100 consecutive digits of π. You must give the index at which that subsequence appears. The 3 is not included. For example, you could print any of the following: ...
emanresu A's user avatar
  • 37.8k
17 votes
38 answers
3k views

Calculating π using the Gregory Leibniz series until n terms

based off my previous challenge, this wikipedia article, and a Scratch project Your task: given i, calculate \$\pi\$ till i ...
SectorCorruptor's user avatar
21 votes
17 answers
2k views

Calculate Pi unto a point using the Nilakantha series

Your task: given a nonzero positive number i, calculate pi using the Nilakantha series unto i terms. The Nilakantha series is as ...
SectorCorruptor's user avatar
8 votes
0 answers
422 views

Turing Machine that outputs pi

Turing Machine Preliminaries A Turing machine is specified by the following data A finite set of symbols S = \$\{s_1,s_2,...\}\$ A finite set of states M = \$\{m_1,m_2,...\}\$ A partially defined ...
QCD_IS_GOOD's user avatar
18 votes
5 answers
2k views

Find a sequence in the binary digits of π

Given a binary sequence of finite length, find the starting position where this sequence first appears in the binary digits of π (after the decimal). You can assume that an answer exists for any input ...
Roman's user avatar
  • 1,993
-4 votes
7 answers
417 views

Print om sign with pi

This time I will give you an easy challenge: Print the Om sign with \$\pi\$!(Sorry for many challenges with \$\pi\$) Here is the om sign drawn using pi numbers: ...
math scat's user avatar
  • 9,248
9 votes
8 answers
2k views

Music with pi and e

Because I forgot to celebrate Pi Day (14.3), let's celebrate with \$\pi\$, \$e\$ (Euler's number) and music! Challenge No, we don't have time to eat a pi-pizza, let's make a program. What you need is ...
math scat's user avatar
  • 9,248
22 votes
14 answers
3k views

Elastic collisions between blocks

The 3Blue1Brown Youtube channel released a video a year ago called "Why do colliding blocks compute pi?" which describes a model where a block A of mass \$a\$ ...
Peter Kagey's user avatar
  • 8,679
20 votes
22 answers
6k views

Pi to the power y, for small y's

Input This task takes no input. Output Your code should compute and print (or return) \$\pi^y\$ for all \$y = \frac11, \frac12, \frac13, \frac14, \frac15, \frac16, \frac17, \frac18, \frac19, \frac1{...
user avatar
-4 votes
6 answers
2k views

Output first \$n\$ digits of \$\pi^{1/\pi}\$

This challenge is to produce the shortest code for the constant \$\pi^{1/\pi}\$. Your code must output the first \$n\$ consecutive digits of \$\pi^{1/\pi}\$, where \$n\$ is given in the input. ...
user avatar
9 votes
9 answers
707 views

Pi Day: Determine if a list of words is correct Pilish

Background Though this is a bit late for Pi Day, I saw an article about Pilish and thought it would make a great challenge. Pilish is created by using a sequence of words where each word's length ...
mbomb007's user avatar
  • 23.4k
-4 votes
3 answers
421 views

Without using numbers, Calculate Pi [duplicate]

Inspired by Nicola Sap's Challenge Goal Your challenge is to simply produce π with 232-1 digits. However today's twist, like the title implies, is to produce it without using any numbers or any π ...
Veskah's user avatar
  • 4,110
-3 votes
7 answers
838 views

Calculate the sum of all odd digits of pi in range [duplicate]

Introduction In the not so distant future with the AI revolution, we will need a way to solve their captchas to prove we're not humans. This challenge was inspired by CommitStrip. Challenge One ...
Mackan90096's user avatar
13 votes
4 answers
702 views

Integers in Base Pi

Background: Pi (π) is a transcendental number, and therefore it has a non-terminating decimal representation. Similar, the representation doesn't terminate if ...
mbomb007's user avatar
  • 23.4k
31 votes
27 answers
7k views

Pi got your number

Challenge : \$\pi\$ is supposed to be infinite. That means every number is contained inside the decimal part of \$\pi\$. Your task will be to take a positive integer on input and return the position ...
The random guy's user avatar
13 votes
35 answers
2k views

Output with the same number of digits of pi as the length of the code

Your challenge is to print x digits of pi where x is your code length. Examples: ...
MD XF's user avatar
  • 13.9k
32 votes
7 answers
3k views

Find Primes in Pi

Primes are everywhere... they hide inside Pi 3.1415926535897932384626433832795028841971693993751 Let's get those primes! The Challenge Given as input an integer ...
user avatar
39 votes
35 answers
4k views

Mix pi and e to make pie!

Everybody knows pi the mathematical constant, the ratio of a circle's circumference to its diameter. 3.14159265358979323846264338327950288419716939937510... You ...
totallyhuman's user avatar
  • 17.2k
18 votes
27 answers
3k views

Sort digits by their first occurrence in pi

Given a non-negative number n, sort the digits of n by their first occurrence in pi. Input can be taken via function cli ...
Linnea Gräf's user avatar
  • 3,059
15 votes
5 answers
1k views

Play the sound of Pi

Yup, you read the title right. play the sound of pi. More specifically, for every digit of pi in the first 1000, map it to a musical note and output the resulting melody to a file. Basically, each ...
sagiksp's user avatar
  • 1,385
12 votes
3 answers
442 views

Natural Pi #2 - River

Goal Given an string with a train of hashes, calculate its total length and divide by the distance from start to finish. Simulation What are we simulating? According to this paper, the ratio of the ...
NonlinearFruit's user avatar
17 votes
10 answers
1k views

Bailey–Borwein–Plouffe Iterations

Bailey–Borwein–Plouffe Iterations We've seen a few pi challenges on PPCG, but none that specifically dictate the algorithm you should be using. I'd like to see implementations of the Bailey–Borwein–...
Magic Octopus Urn's user avatar
7 votes
2 answers
7k views

Print the n-th digit of pi [duplicate]

Task Given an input n, calculate the n-th decimal digit of pi Rules Answer can be a full program or a function. Input must be taken from stdin or from function ...
penalosa's user avatar
  • 553
10 votes
3 answers
624 views

Natural Pi #1 - Sand

Goal Generate (N) random line segments of uniform length (l), check if they cross the equidistant (...
NonlinearFruit's user avatar
21 votes
6 answers
1k views

A Triangular Slice of Squared Pi

Inspired by Bake a slice of Pi Challenge Given input 3 <= n <= 100 and 3 <= y <= n, construct an ...
AdmBorkBork's user avatar
  • 43.4k
38 votes
23 answers
4k views

Natural Pi #0 - Rock

Goal Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns <...
NonlinearFruit's user avatar
88 votes
28 answers
8k views

Bake a slice of Pi

Write a program or function that prints or outputs this exact text (consisting of 142 characters): ...
Copper's user avatar
  • 3,910
12 votes
5 answers
1k views

Runs of Digits in Pi

Your goal is to output the strictly increasing sequence of consecutive, identical digits of pi (π). Each term in the sequence must be one digit longer than the previous. So ...
mbomb007's user avatar
  • 23.4k
37 votes
18 answers
12k views

Find the nth decimal of pi

There are already 30 challenges dedicated to pi but not a single one asks you to find the nth decimal, so... Challenge For any integer in the range of ...
Bassdrop Cumberwubwubwub's user avatar
26 votes
37 answers
8k views

Happy Rounded Pi Day

To celebrate Rounded Pi Day, you must take advantage of today's date to make a program that takes in a circle's diameter and outputs its circumference by multiplying the diameter by 3.1416, where 3....
jmasterx's user avatar
  • 519
19 votes
17 answers
2k views

Pi Day, Pi Minute, or Pi Second?

In this challenge you will need to determine whether it's Pi Day, Pi Minute, or Pi Second. Because Pi is irrational, it wants your code to be as short as possible. Examples No input is provided, ...
Downgoat's user avatar
  • 29k
26 votes
20 answers
2k views

Co-primality and the number pi

Introduction Number theory is full of wonders, in the form of unexpected connections. Here's one of them. Two integers are co-prime if they have no factors in common other than 1. Given a number \$N\$,...
Luis Mendo's user avatar
  • 104k
14 votes
20 answers
3k views

Shorten an already short mathematical expression

For once, I was doing some real work, updating old code, and bumped into an expression that is equivalent to what would be written as πx + ex in good old-fashioned math. I thought it would be possible ...
Adám's user avatar
  • 30.2k
27 votes
9 answers
4k views

Map a random number to pi

A double precision representation of a decimal can only guarantee an accuracy of 15 decimal places, thus pi is approximated as: 3.141592653589793 You can see ...
Stewie Griffin's user avatar
3 votes
4 answers
767 views

Pi Bowling to 10 in 10 [closed]

Your Goal: Estimate pi to at least 10 decimal places. The format is your choice - it can output as a number, as a string, as an output to STDOUT, etc. Seems easy, right? But wait, it's not as simple ...
Glen O's user avatar
  • 2,918
1 vote
4 answers
730 views

Memory is Expensive [closed]

You are a robot. You are stranded in a small cage with weird humans wearing weird suits looking at you. Your solar panel is malfunctioning, and your energy is running out. On the wall there is a ...
matultimate's user avatar
12 votes
3 answers
655 views

Computing truncated digits sums of powers of pi

Given a positive integer n output the sum of the first n decimal digits of the fractional part of πn. Example input and outputs: 1 → 1 2 → 14 3 → ...
orlp's user avatar
  • 39.1k
52 votes
3 answers
6k views

Quiche Lorraine [closed]

Since it was Pi day recently, I have noticed a number of challenges that ask you to calculate pi. Of course, a quiche lorraine is not quite a pie (you can claim a Bonus Score¹ of +1 if you guessed ...
Sanchises's user avatar
  • 9,496
20 votes
5 answers
3k views

Calculate π with quadratic convergence

Write a function or complete program that takes a positive number n and performs n steps of an iterative algorithm for ...
aditsu quit because SE is EVIL's user avatar
11 votes
6 answers
1k views

Transmit Pi... precisely

Following on from Monte Carlo estimator of Pi this challenge is to produce the shortest code for the constant Pi. Except here your code must output consecutive digits of pi forever. This is code ...
user avatar
27 votes
35 answers
4k views

Monte Carlo estimator of Pi

Happy Pi Day everyone! For no reason at all, I'm trying to construct a Monte Carlo estimator of Pi that is as short as possible. Can we construct one that can fit in a tweet? To clarify, what I have ...
keegan's user avatar
  • 397
7 votes
2 answers
456 views

Calculate a pi-based sequence with a pi-based frequence

Introduction Pi is 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089... Let's treat each digit as an instruction as to how to ...
Ypnypn's user avatar
  • 10.9k
11 votes
12 answers
969 views

Piem validator programme

Write a program that defines a function that can check if a string variable called "anything you want or inputted by the user" is or not a piem. (piem = a story or poem in which the word lengths ...
Caridorc's user avatar
  • 2,338
15 votes
2 answers
769 views

Pirrational Numbers

Pi is an irrational number, which means that its decimal representation never terminates or repeats itself. Pi truncated to 41 decimal digits (40 places) is ...
Calvin's Hobbies's user avatar
11 votes
5 answers
1k views

5 Seconds to Find Pie

Pi times e (or Pie if you like ambiguous notation) to 100 decimal places is: ...
Calvin's Hobbies's user avatar
5 votes
3 answers
545 views

When is my piversary?

Since I want to celebrate this definitely not nerdy event, your job is to calculate the piversary (pi-anniversary) of a given date. Input Your code has to have a possibilty to input a date in the ...
izlin's user avatar
  • 1,597
1 vote
4 answers
2k views

Calculate the most digits of pi [closed]

There are a lot of challenges on this site regarding pi, but none that challenge you to calculate as many digits of pi as possible. As you all may know, pi in its decimal form goes on for infinity, ...
CailinP's user avatar
  • 1,053
13 votes
6 answers
1k views

PI window encryption

This is a simple encryption method that uses PI digits to encode a message, the method is simple: The key is just a positive integer that indicates where the window starts then: Given a string to ...
BrunoJ's user avatar
  • 659
27 votes
8 answers
9k views

Pi is still wrong [closed]

Pi is Wrong A common method of computing pi is by throwing "darts" into a 1x1 box and seeing which land in the unit circle compared to the total thrown: ...
Kyle Kanos's user avatar
  • 4,362
56 votes
63 answers
17k views

Output Pi without math [closed]

In as few bytes as possible, your job is to write a program that outputs: 3.14 In celebration of a late Pi day of course! :) Rules You can do it anyway you ...
kukac67's user avatar
  • 2,189