Advertisement
Spocoman

01. Numbers Ending in 7

Sep 20th, 2024 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.30 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.    for i := 0; i < 1000; i++ {
  7.        if i % 10 == 7 {
  8.         fmt.Println(i)
  9.        }
  10.    }
  11. }
  12.  
  13. Оптимизирано решение:
  14.  
  15. package main
  16.  
  17. import "fmt"
  18.  
  19. func main() {
  20.    for i := 7; i <= 997; i += 10 {
  21.         fmt.Println(i)
  22.    }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement