prime number

This commit is contained in:
Mert Gör 🇹🇷 2024-01-04 18:03:26 +03:00
parent 1c7249f618
commit 55446a72e7
Signed by: hwpplayer1
GPG Key ID: 03E547D043AB6C8F
2 changed files with 26 additions and 1 deletions

25
loops/workshop2.go Normal file
View File

@ -0,0 +1,25 @@
package loops
import (
"fmt"
)
func Demo4() {
number := 0
fmt.Println("enter a number")
fmt.Scanln(&number)
is_prime := true
for i := 2; i < number; i++ {
if number%i == 0 {
is_prime = false
}
}
if is_prime == true {
fmt.Println("prime")
} else {
fmt.Println("not prime")
}
}
// I will write it again for now this code is written by the lecturer

View File

@ -11,5 +11,5 @@ func main() {
variables.Demo1() variables.Demo1()
fmt.Print() fmt.Print()
conditionals.Demo3() conditionals.Demo3()
loops.Demo3() loops.Demo4()
} }