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
#J

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
┌──┬───────────────┐
15 13 563
├──┼───────────────┤
22 3 11 107 4931
├──┼───────────────┤
37
├──┼───────────────┤
410429
├──┼───────────────┤
55 7 47
├──┼───────────────┤
611
├──┼───────────────┤
717
├──┼───────────────┤
8 │               │
├──┼───────────────┤
9541
├──┼───────────────┤
1011 1109
├──┼───────────────┤
1117 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