Skip to content

Instantly share code, notes, and snippets.

@mufti1
Created March 5, 2019 06:43
Show Gist options
  • Save mufti1/2dfeda50231d4c7d335c3e01c64a5f16 to your computer and use it in GitHub Desktop.
Save mufti1/2dfeda50231d4c7d335c3e01c64a5f16 to your computer and use it in GitHub Desktop.
Get Prime Number and count it
package main
import (
"fmt"
)
func main() {
var a, b, c int
fmt.Scanf("%v", &a)
for i := 1; i <= a; i++ {
b = 0
if c >= a {
c = c - i
break
}
for j := 1; j <= i; j++ {
if (i % j) == 0 {
b = b + 1
}
}
if b <= 2 {
c = c + i
}
}
fmt.Println(c)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment