this post was submitted on 07 Jun 2023
11 points (100.0% liked)

Programming

13502 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 

you are viewing a single comment's thread
view the rest of the comments
[–] JPAKx4@lemmy.sdf.org 1 points 2 years ago

If you end up doing many numbers, you could create a dictionary, where each number points to the next number in the sequence (ex: [32:16, 16:8, 8:4, 4:2, 2:1], where the first number is the key and the second is the value). If the number already exists in the dictionary, then you know it goes to 1, if it doesn't then add what you just calculated to the dictionary and then continue.