Welcome again to everybody! Make yourself@home. In the time-honoured tradition of our group, here is the weekly discussion thread.

Matrix homeserver and space
Theory discussion group on Matrix
● Find theory on ProleWiki, marxists.org, Anna’s Archive and libgen; audio versions by Socialism For All

You are viewing a single thread.
View all comments View context
4 points
*
num = []
Ms = []
while len(num) <= 5:
    for f in range(1,1000000):
        a = 452021 + f
        mmin = 0
        mmax = 0
        while mmin == 0:
            for n in range(2,a-1):
                if a % n == 0:
                    mmin = n
                if n == a-1 and a % n != 0:
                    mmin = '0'
        while mmax == 0:
            for n in range(a-1,2,-1):
                if a % n == 0:
                    mmax = n
                if n == 2 and a % n !=0:
                    mmax = '0'
        M = int(mmax) + int(mmin)
        if M % 7 == 3:
            num.append(a)
            Ms.append(M)
print(Ms)
print(num)
permalink
report
parent
reply

As a code block.

I.e:

```
Your code
goes here
```

Your code
goes here
permalink
report
parent
reply
2 points

I figured it out! I just needed to use break.

num = []
Ms = []
def Fmmin(va):
    while va == 0:
        for n in range(2, number):
            if number % n == 0:
                va = n
                break
            if n == number - 1 and number - 1 % n != 0:
                va = '0'
    return va
def Fmmax(va):
    while va == 0:
        for n in range(number-1, 1, -1):
            if number % n == 0:
                va = n
                break
            if n == 2 and number % n != 0:
                va = '0'
    return va

for f in range(1,10000000):
    number = 452021 + f
    mmin = 0
    mmax = 0
    mmin = Fmmin(mmin)
    mmax = Fmmax(mmax)
    if int(mmax) > 0 and int(mmin) > 0:
        M = mmax + mmin
        if M % 7 == 3:
            num.append(number)
            Ms.append(M)
    if len(num) >= 5:
        break
print(Ms)
print(num)
permalink
report
parent
reply

You can improve the code by returning n and 0 respectively, no need to use a loop variable. The while va == 0 is either unnecessary (if it runs once) or can cause an endless loop (since nothing changes between iterations)

permalink
report
parent
reply
2 points
*

Fixed it now!

def Fmmin():
    for n in range(2, number):
        if number % n == 0:
            return n
        if n == number - 1 and number - 1 % n != 0:
            return 0
def Fmmax():
    for n in range(number-1, 1, -1):
        if number % n == 0:
            return n
        if n == 2 and number % n != 0:
            return 0
permalink
report
parent
reply

GenZedong

!genzedong@lemmygrad.ml

Create post

This is a Dengist community in favor of Bashar al-Assad with no information that can lead to the arrest of Hillary Clinton, our fellow liberal and queen. This community is not ironic. We are Marxists-Leninists.

This community is for posts about Marxism and geopolitics (including shitposts to some extent). Serious posts can be posted here or in /c/GenZhou. Reactionary or ultra-leftist cringe posts belong in /c/shitreactionariessay or /c/shitultrassay respectively.

We have a Matrix homeserver and a Matrix space. See this thread for more information. If you believe the server may be down, check the status on status.elara.ws.

Rules:

  • No bigotry, anti-communism, pro-imperialism or ultra-leftism (anti-AES)
  • We support indigenous liberation as the primary contradiction in settler colonies like the US, Canada, Australia, New Zealand and Israel
  • If you post an archived link (excluding archive.org), include the URL of the original article as well
  • Unless it’s an obvious shitpost, include relevant sources
  • For articles behind paywalls, try to include the text in the post
  • Mark all posts containing NSFW images as NSFW (including things like Nazi imagery)

Community stats

  • 642

    Monthly active users

  • 3.9K

    Posts

  • 34K

    Comments