1 solutions

  • 0
    @ 2025-3-3 16:34:00

    Python :

    import math
    n= int(input())
    s = 0
    for a in range (1 , n + 1):
        f = True;
        for i in range (2,int(math.sqrt(a))+1):
            if a % i ==0:
                f = False;
                break;
        if f == True and a != 1:
            print(a, end = ' ')
            s += 1;
            if s == 5:
                print()
                s = 0;
    
    • 1

    【入门】求出N以内的全部素数,并按每行五个数显示

    Information

    ID
    10885
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By