Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Search - "factorial"
rant && dev && education
Till now I have just heard of these people but always taught those are just marketing or some person who think that just because they here HTML with some other programming language. BUT THIS IS SOME NEXT LEVEL SHIT.84
Researching to making a small 2D game using constructor classes and while building out classes, was working on my Tree method using fractal geometry and made a wallpaper out of the tree 🌳13
Instructor: "Alright you fresh meat, you're gonna do natural logarithm, factorial, and 2 to the power of N in C++"
My classmates: "Omg this is so hard"
0!=1 is both mathematically correct (because 0 factorial is 1), and logically correct (since 0<1).
I found this interesting.8
My own programming language (still WIP). I got SO excited when I found recursion worked, I even got the simplest factorial recursive function wrong. And then again, once arrays worked, bubble sort it was. I shit you not, once I saw all the numbers printed in order, I had to stand up and walk or I would have jumped out of the chair in excitement.
In case someone is interested, I use LLVM for the backend.4
Bumped my head very badly
To check if my brain was alright, I revised recursive factorial program.3
I've optimised so many things in my time I can't remember most of them.
Most recently, something had to be the equivalent off `"literal" LIKE column` with a million rows to compare. It would take around a second average each literal to lookup for a service that needs to be high load and low latency. This isn't an easy case to optimise, many people would consider it impossible.
It took my a couple of hours to reverse engineer the data and implement a few hundred line implementation that would look it up in 1ms average with the worst possible case being very rare and not too distant from this.
In another case there was a lookup of arbitrary time spans that most people would not bother to cache because the input parameters are too short lived and variable to make a difference. I replaced the 50000+ line application acting as a middle man between the application and database with 500 lines of code that did the look up faster and was able to implement a reasonable caching strategy. This dropped resource consumption by a minimum of factor of ten at least. Misses were cheaper and it was able to cache most cases. It also involved modifying the client library in C to stop it unnecessarily wrapping primitives in objects to the high level language which was causing it to consume excessive amounts of memory when processing huge data streams.
Another system would download a huge data set for every point of sale constantly, then parse and apply it. It had to reflect changes quickly but would download the whole dataset each time containing hundreds of thousands of rows. I whipped up a system so that a single server (barring redundancy) would download it in a loop, parse it using C which was much faster than the traditional interpreted language, then use a custom data differential format, TCP data streaming protocol, binary serialisation and LZMA compression to pipe it down to points of sale. This protocol also used versioning for catchup and differential combination for additional reduction in size. It went from being 30 seconds to a few minutes behind to using able to keep up to with in a second of changes. It was also using so much bandwidth that it would reach the limit on ADSL connections then get throttled. I looked at the traffic stats after and it dropped from dozens of terabytes a month to around a gigabyte or so a month for several hundred machines. The drop in the graphs you'd think all the machines had been turned off as that's what it looked like. It could now happily run over GPRS or 56K.
I was working on a project with a lot of data and noticed these huge tables and horrible queries. The tables were all the results of queries. Someone wrote terrible SQL then to optimise it ran it in the background with all possible variable values then store the results of joins and aggregates into new tables. On top of those tables they wrote more SQL. I wrote some new queries and query generation that wiped out thousands of lines of code immediately and operated on the original tables taking things down from 30GB and rapidly climbing to a couple GB.
Another time a piece of mathematics had to generate all possible permutations and the existing solution was factorial. I worked out how to optimise it to run n*n which believe it or not made the world of difference. Went from hardly handling anything to handling anything thrown at it. It was nice trying to get people to "freeze the system now".
I build my own frontend systems (admittedly rushed) that do what angular/react/vue aim for but with higher (maximum) performance including an in memory data base to back the UI that had layered event driven indexes and could handle referential integrity (overlay on the database only revealing items with valid integrity) or reordering and reposition events very rapidly using a custom AVL tree. You could layer indexes over it (data inheritance) that could be partial and dynamic.
So many times have I optimised things on automatic just cleaning up code normally. Hundreds, thousands of optimisations. It's what makes my clock tick.4
what's the thing that reminds you, that you are a developer?
I said "the time complexity of finding my car in this parking lot is n factorial".11
Haven't used it since and hopefully never will again, but understanding recursion and keyboard input in Assembly (uni project)
After a long (4 days) sleepover with my friends, with 14 hours a day of slamming our heads against abstract registers, we could finally program the factorial and take floating numbers as input and output them on the screen. It was nothing but pain, but the moment we got it, the sky had opened before us :D
Greetings my good people.
I'm currently making a Calculator app. Is there any suggestions you can give me.
I've already added, Square Root function, Factorial, Area of Circle, Volume of Cone, Decimal to Binary function, temperature convertor, and BMI function.8