-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: continue statement was not applied correctly
- Loading branch information
Showing
4 changed files
with
59 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 4; i++ { | ||
for { | ||
break | ||
} | ||
if i == 1 { | ||
continue | ||
} | ||
println(i) | ||
} | ||
} | ||
|
||
// Output: | ||
// 0 | ||
// 2 | ||
// 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
func Primes(n int) int { | ||
var xs []int | ||
for i := 2; len(xs) < n; i++ { | ||
ok := true | ||
for _, x := range xs { | ||
if i%x == 0 { | ||
ok = false | ||
break | ||
} | ||
} | ||
if !ok { | ||
continue | ||
} | ||
xs = append(xs, i) | ||
} | ||
return xs[n-1] | ||
} | ||
|
||
func main() { | ||
println(Primes(3)) | ||
} | ||
|
||
// Output: | ||
// 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters