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

Programming

14025 readers
8 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
 

top 1 comments
sorted by: hot top controversial new old
[–] JPAKx4 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.