All Questions
Tagged with c# mathematics
51
questions
7
votes
2
answers
1k
views
Squaring the two digits in the middle of a four-digit number
I got a four-digit positive number. I need to square the two digits in middle to generate a new number on which the same procedure is applied. The numbers get saved in a list. This loops as long as ...
3
votes
1
answer
5k
views
Probability Chance
I'm creating a game and I need some properties to work as percent chance to hit/dodge. I implemented a small testing program that takes percent chance and the amount of hitting attempts as input and ...
5
votes
2
answers
11k
views
Add item after every nth step
The purpose of the method is to add a list of items after every nth step (5 for example) where the input items are repeated if needed. I'm looking for an overall review and possible how to remove the ...
3
votes
1
answer
10k
views
Calculating distance with Euclidean, Manhattan, and Chebyshev in C#
I am by no means proficient at being able to take mathematical concepts and converting them to code. I was wondering if you guys could look at it and make suggestions on how I could fix it or if my ...
8
votes
1
answer
3k
views
Faster(?) factorial calculations
I saw this question, but was unable to answer because of my inexistant knowledge of Rust, so I decided to try and write an algorithm on my own and put it for review.
There is the casual way to ...
5
votes
1
answer
12k
views
Better implementation of Gaussian Elimination
I made an algorithm in C# that solves any system of linear equations using the Gaussian elimination. There are 2 text boxes in the program for input and output. Input is in the format of the ...
1
vote
1
answer
80
views
A banded interpolator, for any type and any interpolation method
This is an extension of my Attributes system I wrote about in these questions:
Lvl 1 upgradeable attributes
Lvl2 upgradeable attributes
It is unrelated to the core functionality under review in ...
4
votes
2
answers
5k
views
Square Root Calculator
I have now written a simple square root calculator using the division method:
...
5
votes
4
answers
2k
views
Project Euler #5 - Lowest common multiple of 1 through 20
This is my code. All comments welcome. Last time run it only took 335 milliseconds:
...
10
votes
8
answers
13k
views
Calculate square of a number without multiplication
I wrote these two methods to calculate the square of a number:
...
5
votes
3
answers
2k
views
Square root implementations
The question was:
Write a function that calculates the root of a given number.
Answer A = I wrote it for integers. just run up to half of the number
Answer B+C = are for double, using Newton's law....
6
votes
1
answer
336
views
Immutable Matrix
I'm writing implementations of some numerical methods to solve linear equations systems, those implementations use the following Matrix class. I'm trying to get this class immutable, due to that the ...
4
votes
1
answer
796
views
Project Euler #12 very long runtime
Project Euler Problem 12 asks to find the value of the first triangular number to have over 500 divisors, where the \$n\$th triangular number is \$\sum_{i=1}^{n} i\$.
The sequence of triangle ...
10
votes
4
answers
1k
views
Solving for the zero of an arbitrary function
This methods solves for the zero of an arbitrary function using the Bisection Method. It works as desired, but I want to know if the code can be improved or made more readable and if I'm properly ...
15
votes
3
answers
2k
views
Wow that's a big integer! What's its largest prime factor?
I see that there are a few other people who have tackled Project Euler Problem #3. I hope you're not all sick of that question yet. I've not taken a look at those yet (purposely), but am about to now. ...