How to resolve the algorithm Jacobi symbol step by step in the J programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Jacobi symbol step by step in the J programming language
Table of Contents
Problem Statement
The Jacobi symbol is a multiplicative function that generalizes the Legendre symbol. Specifically, the Jacobi symbol (a | n) equals the product of the Legendre symbols (a | p_i)^(k_i), where n = p_1^(k_1)p_2^(k_2)...*p_i^(k_i) and the Legendre symbol (a | p) denotes the value of a ^ ((p-1)/2) (mod p) If n is prime, then the Jacobi symbol (a | n) equals the Legendre symbol (a | n). Calculate the Jacobi symbol (a | n).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Jacobi symbol step by step in the J programming language
Source code in the j programming language
NB. functionally equivalent translation of the Lua program found
NB. at https://en.wikipedia.org/wiki/Jacobi_symbol
jacobi=: {{
assert. (0<x) * 1=2|x
y=. x|y
t=. 1
while. y do.
e=. (|.#:y) i.1
y=. <.y%2^e
t=. t*_1^(*/3 = 4|x,y)+(2|e)*(8|x) e.3 5
'x y'=. y, y|x
end.
t*x=1
}}"0
You may also check:How to resolve the algorithm McNuggets problem step by step in the Phix programming language
You may also check:How to resolve the algorithm Temperature conversion step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Pythagorean triples step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Knuth's algorithm S step by step in the Phix programming language
You may also check:How to resolve the algorithm Church numerals step by step in the OCaml programming language