So Iโm trying to make a shortcut that tries to find prime numbers (here it is, if you want to take a look) and it primarily does this by dividing a number by every number leading up to it (besides from 1 and itself, of course) and if it finds a result that does not include a decimal, it saves the number as the new highest known prime and moves on to the next number. Repeat ad nauseam. And it does do itโs job, but as you could probably guess, itโs kinda slow.
so I made some minor improvements. Made it skip the number if it was even or if it had an easily checkable factor, etc. but I was wondering if it was possible to, if it finds a number that the current number can be divisible by, simply log it and move on to the next number instead of continuing to check every other number. And if you have any other advice for making it faster or cleaner, Id love to hear those suggestions too.
thanks!
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/shortcuts/c...