Sierpinski Number in JavaIn this section, we will learn what is a Sierpinski number and also create Java programs to check if the given number is a Sierpinski number or not. The Sierpinski number program is frequently asked in Java coding interviews and academics. Before moving ahead in this section, first, we will understand the Sierpinski triangle because the Sierpinski number is closely connected to the Sierpinski triangle. Sierpinski TriangleSierpinski triangle or gasket triangle is a gematrical object that is selfsimilar. It means that if we zoom in on the object, it remains the same appearance or structure. One such fractal (a curve or geometric figure, each part of which has the same statistical character as the whole) is the Sierpinski triangle that is formed by drawing a triangle and removing an internal triangle drawn by connecting the midpoints of the outer tringle's sides. This process is repeated recursively and infinitum. In other words, we can also define it as, "a fractal and attractive fixed set with the overall shape of an equilateral triangle. It subdivides a triangle into smaller triangles, recursively." The following figure shows the fourtimes iterated Sierpinski triangle. The formula to count Sierpinski triangle is n=3^{k1}. Sierpinski NumberA Sierpinski number is a positive odd integer k, for which an integer k*2^{n}+1 is allcomposite for allnatural numbers n. In other words, k will be a Sierpinski number if all the members of the following set are composite:
k.2^{n}+1:n∈N
It is an OEIS sequence A076336. The first number of the sequence i.e. 78557 is the smallest Sierpinski number but it is a conjecture (not yet proved). It is a Sierpinski number because it has the covering set i.e., {3, 5, 7, 13, 19, 37, 73}. It is called a covering set because every number of the form 78557*2^{n}+1 is divisible by one of these small primes. The following table shows covering sets of first few Sierpinski numbers.
Sierpinski Number ExampleFirst few Sierpinski numbers are: 78557, 271129, 271577, 322523, 327739, 482719, 575041, 603713, 903983, 934909, 965431, 1259779, 1290677, 1518781, 1624097, 1639459, 1777613, 2131043, 2131099, 2191531, 2510177, 2541601, 2576089, 2931767, 2931991, 3083723, 3098059, 3555593, 3608251. Sierpinski Triangle Java ProgramSierpinskiTriangleExample.java Output:
Next TopicVigesimal in Java
