package main

import (
    "fmt"
    "reflect"
    )

func factors(n int) []int {
    result := []int{}
    for i := 1; i <= n; i++ {
        if n % i == 0 {
            result = append(result, i)
        }
    }
    return result
}

func isPrime(n int) bool {
    // check if two slices are equal
    if reflect.DeepEqual(factors(n), []int{1, n}) {
        return true
    }
    return false
}

func main() { 
    primes := []int{}
    for i := 1; i <= 100; i++ {        
        if isPrime(i) {
            primes = append(primes, i)
        }   
    }
    fmt.Println(primes)
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: