Fun
Only logged in members can reply and interact with the post.
Join SimilarWorlds for FREE »

Prime numbers up to 100

Poll - Total Votes: 16
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
91
97
Show Results
You can only vote on one answer.
Which isn't one?
This page is a permanent link to the reply below and its nested replies. See all post replies »
Elessar · 26-30, M
I was writing a little piece of code to run the Eratosthenes sieve against your poll, because I was too lazy to compute, but just scrolling down delivered me the answer.

Once again laziness won 😌
Classified · M
@Elessar The fastest way to get the right answer is to let someone else solve it. 😋
Elessar · 26-30, M
@Classified The fundamental axiom of (professional) programming.

Your skill isn't to be measured in terms of the quality of code you write, in the efficiency, elegance, correctness or conciseness - but in how effectively you can search GitHub and StackOverflow. 🤪
Classified · M
@Elessar Heard about those, but not sure what they are. 🤔
Elessar · 26-30, M
@Classified GitHub is essentially hosting for open-source projects (/repositories). More often than not, no matter what you're trying to achieve, you'll find some library on there that will greatly help (if not solve your entire issue altogether).

StackOverflow is a Q/A community in which you'll find solutions or ideas for most of your problems.
SW-User
@Elessar This python code does it. I didn't have to reinvent the wheel, just reused the existing code. Instead of array, you can read from a file and loop. For me there's a utility that creates arrays on the fly. I prefer it over file operations.

The below code is not clean, prints the entire array and not very readable, but it does the job.
[image/video deleted]
[image/video deleted]
Elessar · 26-30, M
@SW-User Yeah, I was starting with JavaScript so that I could run it in the browser console directly (hit F12), without even having to copy the list of the numbers above on a separate file 🥴
Elessar · 26-30, M
@SW-User Even better, I could've easily pasted an array of the first prime numbers littler than 100 and do a simple .Contains() check for each item in the array constructed dynamically from the answers above lol
SW-User
@Elessar Happens to me all the time. This is one of my favorite programing memes and it's very true

Elessar · 26-30, M
@SW-User Indeed lol, but the worst feeling imo is when you start working with a library to only find out later in the development that there is some incompatibility, inconsistency, or bug that requires you to switch to something else
SW-User
@Elessar Tell me about it!! And then you upgrade your angular/react/python/java version in your environment and then you keep finishing for failures because the libraries that are compatible in previous version ain't compatible with the new one and you keep refactoring.

For example python 2.xx can works with boto and boto3 but python3 won't work with boto, it must need boto3 if you wanna go cloud which is apparently a big thing. I'm not a programmer but I have learned to program so that I can keep my little power project running and not hire someone to do it paying them a leg and an arm.
Elessar · 26-30, M
@SW-User
Elessar · 26-30, M
@SW-User I'm trying to avoid frontend as much as possible for a reason lol

Plus now that Blazor is a thing it's far easier than having to rely on JS/TypeScript, npm and stuff
SW-User
@Elessar Good to see someone using the good ol jQuery. Nice!!

Me too, never been a fan of front end. My latest passion is AI and Machine learning which I can use a lot in my projects in the future to do fault finding in the connected systems and using data from IoT. I have already started the work.
SW-User
@Elessar BTW, I invite you to join this thread(only if you want :))

https://similarworlds.com/8160244-I-Use-My-Mind/3916994-Why-no-mind-positive-threads-Lets-start-one

And put your solution there. It's definitely a brain thing what you did here and we'd love to see you there. You can put also anything else you want.

We definitely need some programmers on SW. LOL
Elessar · 26-30, M
@SW-User Yeah, I tried typing "jQuery" on the console to see if SW used it, and since it was there I said "cool" lol.

For sure there are far more elegant ways to write that code (I suppose JS/jQuery has a way to calculate the difference between two arrays without diung it manually like I did), but since the subject here was laziness, I didn't mind about searching the documentation lol
SW-User
@Elessar I read somewhere
"10 minutes of reading documentation can save 4 hours of looking for answers".
I find it pretty accurate in my case. LOL
Elessar · 26-30, M
@SW-User Yeah but that snippet took like 30 seconds to write, wasn't worth spending minutes reading the documentation still