The task is to find the triangle of numbers arising from Gilbreath’s conjecture.
It is observed that given a sequence of prime numbers, a sequence can be formed by the absolute difference between the ith and (i+1)th term of the given sequence and the given process can be repeated to form a triangle of numbers. This numbers when forms the elements of Gilbreath conjecture triangle.
The Gilbreath triangle is formed as follows:
- Let us take primes: 2, 3, 5, 7.
- Now the difference between adjacent primes is: 1, 2, 2.
- Now the difference between adjacent elements is: 1, 0.
- Now the difference between adjacent elements is: 1.
- In this way, the Gilbreath triangle is formed as:
2 3 5 7 1 2 2 1 0 1
- This triangle will be read anti-diagonally upwards as
2, 1, 3, 1, 2, 5, 1, 0, 2, 7,
Input: n = 10 Output: 2, 1, 3, 1, 2, 5, 1, 0, 2, 7, Input: n = 15 Output: 2, 1, 3, 1, 2, 5, 1, 0, 2, 7, 1, 2, 2, 4, 11
- The (n, k) th term of the Gilbreath sequence is given by
- F(0, k) is the kth prime number where n = 0.
- Define a recursive function and we can map the (n, k)th term in a map and store them to reduce computation. we will fill the 0th row with primes.
- Traverse the Gilbreath triangle anti-diagonally upwards so we will start from n = 0, k = 0, and in each step increase the k and decrease the n if n<0 then we will assign n=k and k = 0, in this way we can traverse the triangle anti-diagonally upwards.
- We have filled the 0th row with 100 primes. if we need to find larger terms of the series we can increase the primes.
Below is the implementation of the above approach:
2, 1, 3, 1, 2, 5, 1, 0, 2, 7, 1, 2, 2, 4, 11,
- Legendre's Conjecture
- Lemoine's Conjecture
- Ramanujan–Nagell Conjecture
- Program for Goldbach’s Conjecture (Two Primes with given Sum)
- Program to implement Collatz Conjecture
- Maximum Sequence Length | Collatz Conjecture
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Hosoya's Triangle
- Trinomial Triangle
- Pascal's Triangle
- Sum triangle from array
- Find all angles of a triangle in 3D
- Sum of all elements up to Nth row in a Pascal triangle
- Leibniz harmonic triangle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.