Documentation ¶
Overview ¶
Package mathgen is a library for math's questions & answers generation.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdditionResult ¶
Addition Result of addition operator
func AddIntegerN ¶
func AddIntegerN(numberOfAddends int, maxSum int64) (AdditionResult, error)
AddIntegerN generate a operator with sum. Parameter numberOfAddends defines addends in question, it should be greater than 1. Parameter maxSum defines maxsimum of Sum result, it should be greater than 0. If maxSum is greater than or equal numberOfAddends. Question always has pattern: 1 + 1 + 1 ....
Example ¶
package main import ( "fmt" "github.com/ledongthuc/mathgen" ) func main() { questionAndAnswers, _ := mathgen.AddIntegerN(3, 20) fmt.Println("Addends:", questionAndAnswers.Addends) fmt.Println("Sum:", questionAndAnswers.Sum) fmt.Println("Print Question:", questionAndAnswers.StringQuestion()) fmt.Println("Print Full:", questionAndAnswers.String()) }
Output:
func AddIntegers ¶
func AddIntegers(maxSum int64) (AdditionResult, error)
AddIntegers generate a operator with sum of 2 addends. Parameter maxSum defines maxsimum of Sum result, it should be greater than 0. If maxSum = 2, addends always is 1 + 1
Example ¶
package main import ( "fmt" "github.com/ledongthuc/mathgen" ) func main() { questionAndAnswers, _ := mathgen.AddIntegers(20) fmt.Println("Addends:", questionAndAnswers.Addends) fmt.Println("Sum:", questionAndAnswers.Sum) fmt.Println("Print Question:", questionAndAnswers.StringQuestion()) fmt.Println("Print Full:", questionAndAnswers.String()) }
Output:
func (AdditionResult) String ¶
func (a AdditionResult) String() string
String of AdditionResult will present struct data with question answer format a + b + c + ... = sum
func (AdditionResult) StringQuestion ¶
func (a AdditionResult) StringQuestion() string
StringQuestion of AdditionResult will present struct data with question format a + b + c + ... =
type SubtractionResult ¶
SubtractionResult of addition operator
func SubtractIntegerN ¶
func SubtractIntegerN(numberOfSubtrahends int, maxMinuend int64) (SubtractionResult, error)
SubtractIntegerN generate a operator with subtraction. Parameter numberOfSubtrahends defines subtrahends in question, it should be greater than 0. Parameter maxMinuend defines maxsimum of minuend result, it should be greater than 0. If maxMinuend = 1, addends always is 1 - 1 - 0 ....
Example ¶
package main import ( "fmt" "github.com/ledongthuc/mathgen" ) func main() { questionAndAnswers, _ := mathgen.SubtractIntegerN(3, 20) fmt.Println("Minuend:", questionAndAnswers.Minuend) fmt.Println("Subtrahends:", questionAndAnswers.Subtrahends) fmt.Println("Difference:", questionAndAnswers.Difference) fmt.Println("Print Question:", questionAndAnswers.StringQuestion()) fmt.Println("Print Full:", questionAndAnswers.String()) }
Output:
func SubtractIntegers ¶
func SubtractIntegers(maxMinuend int64) (SubtractionResult, error)
SubtractIntegers generate a operator with subtraction of 1 minuend and 1 subtrahend. Parameter maxMinuend defines maxsimum of minuend, it should be greater than 0. If maxMinuend = 1, addends always is 1 - 1
Example ¶
package main import ( "fmt" "github.com/ledongthuc/mathgen" ) func main() { questionAndAnswers, _ := mathgen.SubtractIntegers(20) fmt.Println("Minuend:", questionAndAnswers.Minuend) fmt.Println("Subtrahends:", questionAndAnswers.Subtrahends) fmt.Println("Difference:", questionAndAnswers.Difference) fmt.Println("Print Question:", questionAndAnswers.StringQuestion()) fmt.Println("Print Full:", questionAndAnswers.String()) }
Output:
func (SubtractionResult) String ¶
func (s SubtractionResult) String() string
String of SubtractionResult will present struct data with question answer format a - b - c - d ... = difference
func (SubtractionResult) StringQuestion ¶
func (s SubtractionResult) StringQuestion() string
StringQuestion of SubtractionResult will present struct data with question format a - b - c - d ... =