3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
11 func fact[T interface{ ~int | ~int64 | ~float64 }](n T) T {
21 if got := fact(5); got != want {
22 panic(fmt.Sprintf("got %d, want %d", got, want))
25 if got := fact[int64](5); got != want {
26 panic(fmt.Sprintf("got %d, want %d", got, want))
29 if got := fact(5.0); got != want {
30 panic(fmt.Sprintf("got %f, want %f", got, want))