initial commit
This commit is contained in:
parent
0d8ff083ea
commit
7e9a20f937
17
README.md
17
README.md
@ -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 .
|
||||
```
|
35
primbirthday.go
Normal file
35
primbirthday.go
Normal 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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user