How to resolve the algorithm Wilson primes of order n step by step in the J programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Wilson primes of order n step by step in the J programming language
Table of Contents
Problem Statement
A Wilson prime of order n is a prime number p such that p2 exactly divides:
If n is 1, the latter formula reduces to the more familiar: (p - n)! + 1 where the only known examples for p are 5, 13, and 563.
Calculate and show on this page the Wilson primes, if any, for orders n = 1 to 11 inclusive and for primes p < 18 or, if your language supports big integers, for p < 11,000.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Wilson primes of order n step by step in the J programming language
Source code in the j programming language
wilson=. 0 = (*:@] | _1&^@[ -~ -~ *&! <:@[)^:<:
(>: i. 11x) ([ ;"0 wilson"0/ <@# ]) i.&.(p:inv) 11000
┌──┬───────────────┐
│1 │5 13 563 │
├──┼───────────────┤
│2 │2 3 11 107 4931│
├──┼───────────────┤
│3 │7 │
├──┼───────────────┤
│4 │10429 │
├──┼───────────────┤
│5 │5 7 47 │
├──┼───────────────┤
│6 │11 │
├──┼───────────────┤
│7 │17 │
├──┼───────────────┤
│8 │ │
├──┼───────────────┤
│9 │541 │
├──┼───────────────┤
│10│11 1109 │
├──┼───────────────┤
│11│17 2713 │
└──┴───────────────┘
You may also check:How to resolve the algorithm Mouse position step by step in the Odin programming language
You may also check:How to resolve the algorithm Sorting algorithms/Counting sort step by step in the D programming language
You may also check:How to resolve the algorithm Terminal control/Coloured text step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Fairshare between two and more step by step in the Arturo programming language
You may also check:How to resolve the algorithm Shoelace formula for polygonal area step by step in the VBScript programming language