Advertisement
Spocoman

00. Number Pyramid

Sep 24th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.33 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var num int
  7.     fmt.Scanln(&num)
  8.  
  9.     var counter = 0
  10.    
  11.     for row := 0; row < num || counter < num; row++ {
  12.         for col := 0; col < row && counter < num; col++ {
  13.             counter++
  14.             fmt.Printf("%d ", counter)
  15.         }
  16.         fmt.Println()
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement