The series of increasing prime numbers begins: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, ...

The task applies a filter to the series returning groups of successive primes, (s'primes), that differ from the next by a given value or values.

Example 1: Specifying that the difference between s'primes be 2 leads to the groups:

(3, 5), (5, 7), (11, 13), (17, 19), (29, 31), ...

(Known as Twin primes or Prime pairs)

Example 2: Specifying more than one difference between s'primes leads to groups of size one greater than the number of differences. Differences of 2, 4 leads to the groups:

(5, 7, 11), (11, 13, 17), (17, 19, 23), (41, 43, 47), .... 

In the first group 7 is two more than 5 and 11 is four more than 7; as well as 5, 7, and 11 being successive primes.
Differences are checked in the order of the values given, (differences of 4, 2 would give different groups entirely).

Task

 In each case use a list of primes less than 1_000_000
 For the following Differences show the first and last group, as well as the number of groups found:
 Differences of 2.
 Differences of 1.
 Differences of 2, 2.
 Differences of 2, 4.
 Differences of 4, 2.
 Differences of 6, 4, 2.
 Show output here.

Note: Generation of a list of primes is a secondary aspect of the task. Use of a built in function, well known library, or importing/use of prime generators from other Rosetta Code tasks is encouraged.

references
https://pdfs.semanticscholar.org/78a1/7349819304863ae061df88dbcb26b4908f03.pdf
https://www.primepuzzles.net/puzzles/puzz_011.htm
https://matheplanet.de/matheplanet/nuke/html/viewtopic.php?topic=232720&start=0
#include "isprime.bas"
 
function nextprime( n as uinteger ) as uinteger
    'finds the next prime after n
    if n = 0 then return 2
    if n < 3 then return n + 1
    dim as integer q = n + 2
    while not isprime(q)
        q+=2
    wend
    return q
end function
 
function spd( byval n as integer, d() as integer ) as boolean
    if not isprime(n) then return false
    for i as integer = lbound(d) to ubound(d)
        if not nextprime(n) = n + d(i) then return false
        n+=d(i)
    next i
    return true
end function
 
sub print_set( byval n as uinteger, d() as uinteger )
    print "( ";n;" ";
    for i as integer = lbound(d) to ubound(d)
        print n+d(i);" ";
        n+=d(i)
    next i 
    print ")"
end sub
 
function count_below( max as uinteger, d() as uinteger ) as uinteger
    dim as uinteger c = 0, last = 0
    for n as uinteger = 2 to max-d(ubound(d))
        if spd(n, d()) then
            c+=1
            if c=1 then print_set( n, d() )
            last = n
        end if
    next n
    print_set(last, d())
    return c
end function
 
dim as integer n, c
 
'example 1, differences of 2
redim as uinteger d(0)
d(0) = 2
print "Differences of 2 (the twin primes)"
c = count_below(1000000, d())
print "Number of occurrences: ", c
 
'example 2, difference of 1
d(0) = 1
print
print "Differences of 1"
c = count_below(1000000, d())
print "Number of occurrences: ", c
 
'example 3, differences of 2,2
redim as uinteger d(1)
d(0) = 2 : d(1) = 2
print
print "Differences of 2, 2"
c = count_below(1000000, d())
print "Number of occurrences: ", c
 
'example 4, differences of 2,4
d(1) = 4
print
print "Differences of 2, 4"
c = count_below(1000000, d())
print "Number of occurrences: ", c
 
'example 5, differences of 2,2
d(0) = 4 : d(1) = 2
print
print "Differences of 4, 2"
c = count_below(1000000, d())
print "Number of occurrences: ", c
 
'example 6, differences of 6,4,2
redim as uinteger d(2)
d(0) = 6 : d(1) = 4 : d(2) = 2
print
print "Differences of 6, 4, 2"
c = count_below(1000000, d())
print "Number of occurrences: ", c