this post was submitted on 16 Jul 2025
41 points (100.0% liked)

Ask Lemmy

33292 readers
1843 users here now

A Fediverse community for open-ended, thought provoking questions


Rules: (interactive)


1) Be nice and; have funDoxxing, trolling, sealioning, racism, and toxicity are not welcomed in AskLemmy. Remember what your mother said: if you can't say something nice, don't say anything at all. In addition, the site-wide Lemmy.world terms of service also apply here. Please familiarize yourself with them


2) All posts must end with a '?'This is sort of like Jeopardy. Please phrase all post titles in the form of a proper question ending with ?


3) No spamPlease do not flood the community with nonsense. Actual suspected spammers will be banned on site. No astroturfing.


4) NSFW is okay, within reasonJust remember to tag posts with either a content warning or a [NSFW] tag. Overtly sexual posts are not allowed, please direct them to either !asklemmyafterdark@lemmy.world or !asklemmynsfw@lemmynsfw.com. NSFW comments should be restricted to posts tagged [NSFW].


5) This is not a support community.
It is not a place for 'how do I?', type questions. If you have any questions regarding the site itself or would like to report a community, please direct them to Lemmy.world Support or email info@lemmy.world. For other questions check our partnered communities list, or use the search function.


6) No US Politics.
Please don't post about current US Politics. If you need to do this, try !politicaldiscussion@lemmy.world or !askusa@discuss.online


Reminder: The terms of service apply here too.

Partnered Communities:

Tech Support

No Stupid Questions

You Should Know

Reddit

Jokes

Ask Ouija


Logo design credit goes to: tubbadu


founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] Arkouda@lemmy.ca 5 points 1 day ago
mainNumber = 10000
count = 0

def addNumber():
    global mainNumber
    if mainNumber >= 0:
        mainNumber += 10
    if mainNumber >= 9:
        mainNumber += 7
    else:
        mainNumber += 13

def subNumber():
    global mainNumber
    if mainNumber >= 10:
        mainNumber -= 6
    elif mainNumber >= 100:
        mainNumber -= 56
    elif mainNumber >= 1000:
        mainNumber -= 560
    else:
        mainNumber -= 2

def multNumber():
    global mainNumber
    if mainNumber <= 100:
        mainNumber = mainNumber * 2
    else:
        mainNumber = mainNumber * 3

def divNumber():
    global mainNumber
    if mainNumber > 1000:
        mainNumber = mainNumber / 5
    if mainNumber < 1000:
        mainNumber = mainNumber / 3
    if mainNumber < 0:
        mainNumber = mainNumber * -1

while mainNumber != 1:
    count += 1
    addNumber()
    subNumber()
    multNumber()
    divNumber()
    print(mainNumber)
    if count == 1000:
        break

This is not the most interesting script in the world, I made it to practice while loops that I absolutely sucked at and see what funky things happen.

This script does nothing if you put in mainNumber = 1 for obvious reasons, but if you put in 2-21 it will evaluate to 21.99999999999999, 22 evaluates to 22 1000 times, and mainNumber = 23 or higher evaluates to 22.00000000000001.

I have not found a whole number that doesn't follow this pattern yet (Truthfully haven't dug as far as I would like) but it is interesting how this little practice script did something like this when I was just messing around.