initial commit

This commit is contained in:
Raphael Martin 2024-01-16 17:19:31 +01:00
parent 0d8ff083ea
commit 7e9a20f937
3 changed files with 55 additions and 0 deletions

View File

@ -1,2 +1,19 @@
# go_primebday
## requierments
- you need go to run the example
on debian based os you can install it with
```
apt install golang-go
```
## execute
to execute run in the repository
```
go run .
```

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module example/primbirthday
go 1.21.6

35
primbirthday.go Normal file
View File

@ -0,0 +1,35 @@
package main
import "math"
import "fmt"
func getNextPrimeBdays(age uint, countNextBdays uint){
var ageLimit uint = 100
var denominator uint
var primenum bool
for countNextBdays > 0 {
for age = 32; age <= ageLimit; age++ {
primenum = true
for denominator = 2; denominator <= age/2; denominator++ {
if math.Mod(float64(age), float64(denominator)) == 0 {
primenum = false
break
}
}
if primenum == true {
fmt.Printf("%d is a prime number bday\n", age)
countNextBdays--
if countNextBdays == 0{
break
}
}
}
}
}
func main () {
getNextPrimeBdays(32,10)
}