Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (33 sloc) 0.599 kb
package main
import (
"fmt"
"sort"
"strconv"
)
func IsPandigital(number int) bool {
digits := []int(strconv.Itoa(number))
sort.Ints(digits)
sequence := make([]int, len(digits))
for i, counter := '1', 0; i < len(digits) + '1'; i, counter = i + 1, counter + 1 {
sequence[counter] = i
}
for i, digit := range digits {
if digit != sequence[i] {
return false
}
}
return true
}
func main() {
max := 0
primes := GetPrimes(10000000)
for prime := range primes {
if prime == 0 {
break
}
if IsPandigital(prime) && prime > max {
max = prime
}
}
fmt.Println(max)
}
Jump to Line
Something went wrong with that request. Please try again.