Esempio n. 1
0
func main() {
	isPrime := primegen.Map(1000000)
	p := append([]int64{0}, primegen.SliceFromMap(isPrime)...)

	for n := uint64(1); ; n++ {
		p2 := uint64(p[n] * p[n])
		r := (mu.ModPowUint64(uint64(p[n]-1), n, p2) + mu.ModPowUint64(uint64(p[n]+1), n, p2)) % p2
		if r > 10000000000 {
			fmt.Printf("%v\n", n)
			break
		}
	}
}
Esempio n. 2
0
func IsPrimitive(num, prime uint64) bool {
	tmp := prime - 1
	idx := uint64(2)
	for idx*idx <= tmp {
		if tmp%idx == 0 {
			if mathutil.ModPowUint64(num, idx, prime) == 1 || mathutil.ModPowUint64(num, tmp/idx, prime) == 1 {
				return false
			}
		}
		idx += 1
	}
	return true
}
Esempio n. 3
0
func main() {
	var ans uint64
	for i := 1; i < 1001; i++ {
		ans += mathutil.ModPowUint64(uint64(i), uint64(i), 1e10)
	}
	fmt.Println(ans % 1e10)
}
Esempio n. 4
0
func main() {
	var prime uint64 = 5
	var n uint64 = 1e17
	var result uint64 = 5
	for prime < 100000 {
		if mathutil.ModPowUint64(10, n, 9*prime) != 1 {
			result += prime
		}
		prime, _ = mathutil.NextPrimeUint64(prime)
	}
	fmt.Println(result)
}
Esempio n. 5
0
func main() {
	var prime uint64 = 7
	var n uint64 = 1e9
	var count int = 0
	var result uint64 = 0
	for count < 40 {
		if mathutil.ModPowUint64(10, n, 9*prime) == 1 {
			count += 1
			result += prime
		}
		prime, _ = mathutil.NextPrimeUint64(prime)
	}
	fmt.Println(result)
}
Esempio n. 6
0
// HasFactorUint64 returns true if d | Mn. Typical run time for a 64 bit factor
// and a 32 bit exponent is < 30 µs.
func HasFactorUint64(d uint64, n uint32) bool {
	return d == 1 || d&1 != 0 && mathutil.ModPowUint64(2, uint64(n), d) == 1
}