Pull specific lines from long file based on formula

For people who want to pull a number of lines from a long file using a specific formula

n (number of iterations in a loop)
a (offset number)
b (stretch factor)

example with n {1..100}

for (( n=1; n<101; n++ )); do awk -v n=$n 'NR==a+(b*n)' a=0 b=1 inputfile >>outputfile

This reads the file 100 times. If the file has 10^8 lines that will take all day.
You can embed the loop into awk, which is not super fast, but is acceptable:

limit=101
a=0
b=1
awk -v lim=$limit '
     {   
     for(n=1; n<lim; n++) 
       { 
          if(NR==a+(b*n) )
            {print $0 }
       } '  a=$a b=$b  inputfile > outputfile

Could call quit once the last match if found - stops reading all 10^8 lines when we just wanted 1 - 100:

limit=100
a=0
b=1
awk -v lim=$limit '
     {   
     for(n=1; n<=lim; n++) 
       { 
          if(NR==a+(b*n) )
            {print $0 ; if (n==lim) quit }
       } '  a=$a b=$b  inputfile > outputfile