func CalculateIsPrimeAndLiars(n int) (bool, []int) {
	var firstTruthfulStarWitnessIndex int = -1
	for idx, witness := range StarWitnessesInt32 {
		if !IsStrongProbablePrimeToBaseA(n, witness) {
			firstTruthfulStarWitnessIndex = idx
			break
		}

		if n < 2047 {
			// checking just 2 is enough for n < 2047
			return true, nil
		}

		if idx == 1 && n < 1373653 {
			return true, nil
		}

		if idx == 2 && n < 25326001 {
			return true, nil
		}
	}

	if firstTruthfulStarWitnessIndex == -1 {
		return true, nil
	}

	liars := make([]int, 0, 64)
	var idxHint int = 0
	for a := 2; a < StarWitnessesInt32[firstTruthfulStarWitnessIndex]; a++ {
		if a == StarWitnessesInt32[idxHint] {
			// already checked
			liars = append(liars, a)
			liars = append(liars, n-a)
			idxHint++
		} else if IsStrongProbablePrimeToBaseA(n, a) {
			liars = append(liars, a)
			liars = append(liars, n-a)
		}
	}

	halfN := n / 2
	for a := StarWitnessesInt32[firstTruthfulStarWitnessIndex] + 1; a <= halfN; a++ {
		if IsStrongProbablePrimeToBaseA(n, a) {
			liars = append(liars, a)
			liars = append(liars, n-a)
		}
	}

	return false, liars
}
// CalculateIsPrimeAndLiars both determines if n is prime deterministically and
// any lying witnesses. n must be odd and >= 3. If the number is prime then it's
// not possible for a witness to lie and so the slice is nil rather than empty.

CalculateIsPrimeAndLiars both determines if n is prime deterministically and
any lying witnesses. n must be odd and >= 3. If the number is prime then it's
not possible for a witness to lie and so the slice is nil rather than empty.
// CalculateIsPrimeAndLiars both determines if n is prime deterministically and // any lying witnesses . n must be odd and > = 3 . If the number is prime then it ' s // not possible for a witness to lie and so the slice is nil rather than empty .
func CalculateIsPrimeAndLiars(n int) (bool, []int) {
	var firstTruthfulStarWitnessIndex int = -1
	for idx, witness := range StarWitnessesInt32 {
		if !IsStrongProbablePrimeToBaseA(n, witness) {
			firstTruthfulStarWitnessIndex = idx
			break
		}
		if n < 2047 {
			return true, nil
		}
		if idx == 1 && n < 1373653 {
			return true, nil
		}
		if idx == 2 && n < 25326001 {
			return true, nil
		}
	}
	if firstTruthfulStarWitnessIndex == -1 {
		return true, nil
	}
	liars := make([]int, 0, 64)
	var idxHint int = 0
	for a := 2; a < StarWitnessesInt32[firstTruthfulStarWitnessIndex]; a++ {
		if a == StarWitnessesInt32[idxHint] {
			liars = append(liars, a)
			liars = append(liars, n-a)
			idxHint++
		} else if IsStrongProbablePrimeToBaseA(n, a) {
			liars = append(liars, a)
			liars = append(liars, n-a)
		}
	}
	halfN := n / 2
	for a := StarWitnessesInt32[firstTruthfulStarWitnessIndex] + 1; a <= halfN; a++ {
		if IsStrongProbablePrimeToBaseA(n, a) {
			liars = append(liars, a)
			liars = append(liars, n-a)
		}
	}
	return false, liars
}
func CalculateIsPrimeAndLiars ( n int ) ( bool , [ ] int ) { var firstTruthfulStarWitnessIndex int = - 1 for idx , witness := range StarWitnessesInt32 { if ! IsStrongProbablePrimeToBaseA ( n , witness ) { firstTruthfulStarWitnessIndex = idx break } if n < 2047 { return true , nil } if idx == 1 && n < 1373653 { return true , nil } if idx == 2 && n < 25326001 { return true , nil } } if firstTruthfulStarWitnessIndex == - 1 { return true , nil } liars := make ( [ ] int , 0 , 64 ) var idxHint int = 0 for a := 2 ; a < StarWitnessesInt32 [ firstTruthfulStarWitnessIndex ] ; a ++ { if a == StarWitnessesInt32 [ idxHint ] { liars = append ( liars , a ) liars = append ( liars , n - a ) idxHint ++ } else if IsStrongProbablePrimeToBaseA ( n , a ) { liars = append ( liars , a ) liars = append ( liars , n - a ) } } halfN := n / 2 for a := StarWitnessesInt32 [ firstTruthfulStarWitnessIndex ] + 1 ; a <= halfN ; a ++ { if IsStrongProbablePrimeToBaseA ( n , a ) { liars = append ( liars , a ) liars = append ( liars , n - a ) } } return false , liars }
CalculateIsPrimeAndLiars both determines if n is prime deterministically and
any lying witnesses.
CalculateIsPrimeAndLiars both determines if n is prime deterministically and any lying witnesses .
// checking just 2 is enough for n < 2047
 // already checked
