Latest posts

Finding the two closest factors of an integer

Finding the two closest factors of an integer

I was browsing the latest C# questions on StackOverflow, and came across one that caught my eye. Sadly, it was quickly closed by people who, in my opinion, didn't read it properly. The question was...

I am trying to write a program to find the factor of a number with minimum difference. For Ex: for 20 it should be 4x5 or vice versa. How can this be achieved for a really BIG number. lets say 989287498274928743928174192847219347123984723498. Please guide

Ignoring the usual SO rules about showing some effort or research, the question is not simply "How do I find the factors of n?", which is what all the linked answers were about. This question was how to find the two closest factors. Sure you can do that by finding them all, then sorting them by their difference, but for a big number, that's hugely inefficient. There are ways of solving this specific question much more efficiently, which is what I decided to do.

Using Linq to debunk the Feng Shui about the number of days in December

Using Linq to debunk the Feng Shui about the number of days in December

Debunking the Internet myth that this year December (or whatever month is chosen) will have 5 Saturdays, 5 Sundays and 5 Mondays, and how this only happens once every 823 years.

It's junk, and I proved it using Linq. Afterwards, I realised that I could prove it without Linq, had I only thought about the question first. Still, it was an interesting exercise, both in Linq and in thinking.

OnInitializedAsync() - No suitable method to override

OnInitializedAsync() - No suitable method to override

I've been working on a new Blazor project for a few weeks, and have been bothered by the number of seemingly odd errors reported in the Visual Studio error panel. The main reason they bothered me (other than the unhelpful fact that they all claim to be on line 1 character 1 of the relevant file, which isn't very helpful) is that the code runs fine. Whilst this has been annoying me, as things were working, I didn't spend too much time on it.

However, I just ran into another problem, and the solution turned out to solve this one as well.