The math tag has no wiki summary.
0
votes
0answers
20 views
Approximating square root (loops and functions exercise)
Just looking for some feedback on my solution for Tour of Go Exercise 24 - Loops and Functions. Is there anything that looks like a wrong way to do things in go? anything I could have done better?
...
3
votes
2answers
77 views
How is my program for computing the Hardy-Ramanujan number?
I'm just wanting feedback on the efficiency, design and layout of this code if possible please. I suspect it's weird having a constructor with nothing in. I'd be grateful if it could be explained how ...
0
votes
1answer
38 views
How to reduce runtime of gene data processing program?
This program takes a huge data set as input, processes it, calculates and then writes the output to an array. Most calculations may be quite simple, such as summation. In the input file, there are ...
0
votes
0answers
42 views
Math formulas in Haskell
I wrote some math formulas in Haskell and was wondering about how to clean the code up and make it more readable.
import Math.Gamma
pdf :: Double -> Double -> Double -> Double -> Double
...
2
votes
1answer
31 views
Fraction program — Code Review and Suggestions
Today I started to make a class called Fraction, where the class will act just like a fraction does in real mathematics. I am doing this just for the challenge, it has been several months since I last ...
1
vote
1answer
37 views
Reducing steps for long addition program
This is a program that I wrote to add two numbers together that are too large for the C language to store. It stores the numbers as strings instead and processes one digit at a time. But I suspect ...
1
vote
0answers
48 views
Improving readability of Boolean adder generator?
Today I've noticed that the source code for a Boolean adder is very repetitive, so I wrote a Python script to generate the C source code. The script generates an adder of varying size depending on ...
0
votes
1answer
43 views
Testing if numbers in the array can be added up to equal the largest number in the array
Okay, here's a challenge at Coderbyte that completely stumped me. I came up with a solution, but I know it is flawed.
Have the function ArrayAdditionI(arr) take the array of numbers stored in arr ...
23
votes
3answers
1k views
Why is my C program for calculating Euler's constant of poor quality?
I was trying to post this code to a Wikipedia article, but it was soon removed. I then asked about the code in the page's talk section, and some other contributors said that is was "very poor" and ...
5
votes
2answers
131 views
Finding greatest value in array smaller than x
Code review requested to make this code simpler, cleaner, and better. Input array is sorted.
This program finds the greatest number smaller than x. So, in an array [10 20 30 40] and x = 25, the ...
5
votes
3answers
235 views
Adding two big integers represented as strings
class MyClass{
static Integer carry = 0;
public static void main(String args[]){
String s1 = "7654729850328997631007285998163550104";
String s2 = ...
0
votes
1answer
40 views
Pygame snap mouse to grid?
The game I am working with is a block game. It generates terrain and then allows you to freely mine and place blocks as you wish (sound familiar Cx) BUT! there is a problem. I have a code that snaps ...
1
vote
1answer
87 views
Best way to work out angle between points?
I have the following JavaScript code to work out the angle between two points (clockwise). The code I have seems a bit "hacky" to me, as I have a while loop ensuring the number is not negative (to ...
3
votes
2answers
73 views
Attempting to efficiently compute the largest prime factor
As per the help, here's what I'm looking for from this post: best practice and practical advice about (what I think is describable as) buffering the output of a function.
So I'm working on the third ...
2
votes
1answer
130 views
How to write better an sqrt (square root) function in Scala
As an exercise in learning Scala, I implemented a square root function like this:
def sqrt(x: Double): Double = {
if (x < 0) throw new IllegalArgumentException("negative numbers not ...
1
vote
2answers
63 views
Cleaning and simplifying function that returns a number based on certain values
I have a rather clunky function that returns a number based on certain values:
local = {'abs154': '4'}
w12,sv2,sv4,sv6,sv8,sv10,sv12=75,95,110,104,101,110,116
supers = [["5", w12], ["6", w12], ...
1
vote
1answer
71 views
Simple way to decrement number within a repeating range
I currently have a solution to increment numbers within a range:
i % x + 1
Where x is the maximum number in the range and i is the previous number.
It is nice and simple, and gives this array: ...
3
votes
0answers
101 views
Optimizing numpy/python for speed
This is my first real python script after "Hello, World!" I'd really appreciate feedback to make it faster and more efficient.
The purpose of this script is to calculate the nonlinear reflection ...
0
votes
1answer
51 views
Issue regarding game velocity
So, this is a thing. I've got a simple little 2D game where a character can run left and right and jump. My problem here is that I've got two velocities, xVel and yVel, that I need to increment as the ...
2
votes
2answers
244 views
Python — polynomial operations class
This Python class takes a GF2 (finite field mod 2, basically binary) polynomial in string form, converts it to a binary value, then does arithmetic operations, then converts the result back into a ...
0
votes
1answer
148 views
Is my 4x4 Matrix multiplication on a 1d float array correct?
I'm trying to develop my own Math library to use on a Voxel Engine, but I'm worried about Matrices multiplication. Everywhere I saw ppls using 4x4 Matrices on a 2d Float Array but i'm using a 1d Float ...
1
vote
1answer
98 views
Generating Pandigital Numbers
A Base10 Pandigital Number is a number which uses all the digits 0-9 once. i.e.
1234567890
2468013579
etc...
My naive solution was just to use a bunch of nested loops to do this but it's quite ...
16
votes
12answers
6k views
Asks the user to input 10 integers, and then prints the largest odd number
I have written a piece of python code in response to the following question and I need to know if it can be "tidied up" in any way. I am a beginner programmer and am starting a bachelor of computer ...
0
votes
1answer
103 views
Function that multiplies all numbers between “a” and “b” with do loop
I'm making a function that multiplies all numbers between an "a" input and a "b" input with do loop. If you please, check my function and say what's wrong since I don't know loops very well in Scheme.
...