Copyright | Copyright (C) 2022 Yoo Chung |
---|---|

License | GPL-3.0-or-later |

Maintainer | dev@chungyc.org |

Safe Haskell | Safe-Inferred |

Language | GHC2021 |

Some solutions to Problems.P45 of Ninety-Nine Haskell Problems.

## Synopsis

- isGaussianPrime' :: Complex Integer -> Bool

# Documentation

isGaussianPrime' :: Complex Integer -> Bool Source #

Using Fermat's two-square theorem, it can be shown that a Gaussian integer \(a+bi\) is prime if and only if it falls into one of the following categories:

- |a| is prime and \(|a| \equiv 3 \mod 4\), if \(b=0\).
- |b| is prime and \(|b| \equiv 3 \mod 4\), if \(a=0\).
- \( a^2 + b^2 \) is prime, if \( a \neq 0 \) and \( b \neq 0 \).

Use this property to determine whether a Gaussian integer is a Gaussian prime.