Using Recursion to find Primes

Please design 3 to start a program to find primes in ascending order, find 100 primes, and output numbers from large to small in comma-separated order.

however, the program must meet the following conditions.
do not use circular syntax such as For,While. (use recursive processing instead)
speed up. (for example, multithreading)-sharp-sharp-sharp topic description

Jul.14,2022

<?php
function digui($a,$b)
{

    if($a%$b == 0) {
        return $a;
    }else {
        if($b == 2) {
            return false;
        }
        return digui($a,$b-1);
    }
}

function test($num,$arr=[])
{
    $res = digui($num,$num-1);

    if(!$res) {
        array_push($arr,$num);
    }

    if (count($arr) == 100)
    {
        //xu
        rsort($arr);
        //implode = , 
        echo implode(',',$arr);
        exit();
    }
    $numPP; 
    test($num,$arr);
}
test(3,[]);



res = [3]


def isprime(n, i):
    if i == len(res):
        return True
    elif n % res[i] == 0:
        return False
    else:
        return isprime(n, i + 1)


def find(cur):
    if len(res) < 100:
        if isprime(cur, 0):
            res.append(cur)
        cur += 2
        find(cur)


find(5)
print(res)

time complexity O (nk), where kink 100th n is the k th prime of P (k) / 2, and concurrency

is not supported.
Menu