26: reciprocal cycles

This commit is contained in:
VicRen
2020-10-26 11:13:58 +08:00
parent 117fc7ab5f
commit 0b3b448000
2 changed files with 89 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
package main
import (
"reflect"
"testing"
)
func Test_findDecimalOfOneNth(t *testing.T) {
type args struct {
n int
}
tt := []struct {
name string
args args
want int
}{
{
"2",
args{2},
1,
},
{
"4",
args{4},
2,
},
{
"6",
args{6},
1,
},
{
"7",
args{7},
6,
},
{
"10",
args{10},
1,
},
{
"100",
args{100},
2,
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
if got := findCycleLengthOfOneNth(tc.args.n); !reflect.DeepEqual(got, tc.want) {
t.Errorf("findCycleLengthOfOneNth() = %v, want %v", got, tc.want)
}
})
}
}