Answer the question
In order to leave comments, you need to log in
How to open a function every X times?
Let's say I want to create a new file when 2k numbers are reached.
package main
import (
"fmt"
"log"
)
var start, end, split, i = 1, start+1000, 10000, 0
func main() {
fmt.Println("Enter: start, end, split")
fmt.Scanf("%d %d %d", &start, &end, &split )
for i := 0; i < split/1000; i++ {
for j := start; j < end; j++ {
//start отвечает за стартовую позицию генерации чисел
//end отвечает за конечную позицию генерации чисел
}
//достигли 2, 4, 6, 8, 10 - открываем функцию
//шаг позиции 1000
log.Printf("STEP: %d | %d - %d", end-start, start, end)
start, end = end+1, end+1001
}
}
Answer the question
In order to leave comments, you need to log in
If the numbers are in order, then you just need to consider the remainder of dividing the number by 2000.
if i % 2000 == 0 {....}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question