1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Goldbach Python Output

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    I made a python code for Goldbach conjecture. The thing is my output looks like this

    Enter the lower limit: 8
    Enter the Upper limit: 10
    8 = 3 + 5
    10 = 3 + 7
    10 = 5 + 5


    What I want my output to look like is

    8 = 3 + 5
    10 = 3 + 7 = 5 + 5


    Is there any way to format it as such?

    I am posting only the for loop:

    for n in range (lo_limit, up_limit + 1): #lo_limit and up_limit is what you input
    if (n % 2 == 0):
    for a in range (1, n + 1):
    if is_prime(a): #is_prime represent numbers that are prime
    for b in range(1, n + 1):
    if is_prime(b):
    if (a + b == n):
    if (a <= b):
    print(n, "=", a, "+", b)


    main()

    Continue reading...

Compartilhe esta Página