Help please solve the problem.

Gordon's algorithm for generating a strongly prime number:

  1. Generate two large primes s and t of the same length.

  2. Select the number i0 . Find the first prime number in the sequence 2it + 1 , where i = i0 , i = i + 1 , .... Designate this number r = 2it + 1 .

  3. Calculate p0 = 2 (s ^ r-2 mod r) s - 1 .

  4. Choose the number j0 . Find the first prime number in the sequence p0 + 2jrs , where j = j0 , j = j + 1 , .... Denote this number p = p0 + 2jrs .

  5. Return p .

Implemented all items except 2 and 4 .
In the second paragraph, you need to find the number r .
In the fourth paragraph, you need to find the number p .

Perhaps in both points you need to use cycles, but I still do not understand how to write them correctly to calculate the numbers r and p .

# Пункт 1 s = 78479 # Сгенерированное число s t = 86399 # Сгенерированное число t # Пункт 2 i0 = 3 # Выбранное число i0 r = None # Проблема здесь # Пункт 3 p0 = 2 * (pow(s, r - 2) % r) * s - 1 # Вычисленное число p0 # Пункт 4 j0 = 9 # Выбранное число j0 p = None # Проблема здесь # Пункт 5 print(p) # Вывод числа p 

    0