I had an interview and was asked a question that I'd like to understand the solution. The Question Create a recursive function that returns the number of possible combinations of arrays of a given length that could be made from an array of non-repeat

I am solving how many times a zero occus on an odometer. I count +1 everytime I see a zero. 10 -> +1 100-> +2 because in 100 I see 2 zero's 10004 -> +3 because I see 3 zero's So I get, 1 - 100 -> +11 1 - 500 -> +91 1 - 501 -> +92 0 - 429

Suppose I have 8 bits. Then total possible combinations would be 2^8 . Is there some encryption technique I could use so that I can identify all those 256 numbers with less bits ( say 5 or 6 bits). I know this is kind of hard ( and impossible ) . But

This question already has an answer here: Python division 11 answers I'm attempting to calculate e^x using recursion, e^x = e^(x/2)*e^(x/2), and the third order Maclaurin expansion for e^x and the script keeps returning 1. I'm not looking for a highe

I have recently been reading about quaternions and was wondering if it is possible to create a system which allows you to create a twist system which doesn't flip at +/-180 and allows for 360 degree twisting? Every test I've done keeps coming back to

This question already has an answer here: JavaScript closure inside loops – simple practical example 32 answers How do JavaScript closures work? 88 answers I know that floating point variables require work arounds when dealing with 0.1, 0.2, 0.3 etc.

Perhaps I am incredibly stupid, but I have no idea why the output is negative? It is really affecting my program <?php $vone = 10833087074.438; $massone = 1; $keone = $vone ^ 2; echo $keone; echo "<BR>"; $keone = $keone * $massone; echo

This question already has an answer here: Is floating point math broken? 20 answers I have the following function: var a = 0.1; var b = 0.2; function checkValue(){ if(a + b === 0.3){ alert('statement is true'); } else { alert('statement is false'); }

This is part of a bigger question. Its actually a mathematical problem. So it would be really great if someone can direct me to any algorithm to obtain the solution of this problem or a pseudo code will be of help. The question. Given an equation che

Consider the following functions: #include <iostream> #include <iomanip> #include <cmath> #include <limits> template <typename Type> inline Type a(const Type dx, const Type a0, const Type z0, const Type b1) { return (std::sqr

GNU GMP provides a functions called mpz_powm(rop, base, exp, mod) which allows me to power a very big integer value by another very big integer value. The function also forces me to modulate the result by the 4th parameter. That's what the "m" s

I would like to solve the following recurrence relation: T(n) = 2T(√n); I'm guessing that T(n) = O(log log n), but I'm not sure how to prove this. How would I show that this recurrence solves to O(log log n)?One idea would be to simplify the recurren

I'm reading this paper (page 3 and page 8): http://acl.ldc.upenn.edu/P/P05/P05-1077.pdf where it defines a permutation function to generate a permutation of a signature. The signature is a string of bits like "1001" It defines the permutation fu

I am making a calculator and I want to make sure that user is able to enter a "Negative Decimal Number" I see the option in the xml file separately for example in order to put the Decimal Number, the EditText's inputType must be numberDecimal an

I am trying to calculate the exponential of -1200 in python (it's an example, I don't need -1200 in particular but a collection of numbers that are around -1200). >>> math.exp(-1200) 0.0 It is giving me an underflow; How may I go around this prob

This is one of the most bizarre problems I've run into so far, I have two numbers which I am trying to add up in php but for some reason php does not give me the correct result. I am trying to add the $itemPrice with the $shipPrice which is 3.50 + 2.

I wrote a research project in matlab that uses quite a few functions which I do not want to re-implement in C++, so I'm looking for libraries to handle these for me. The functions I need are: (by order of importance) Hilbert transform Matrix function

I am working in c++ application. And its new to me. Here I write a function which gain two coordinates of a line. I have to process these coordinates and find another point which in that same line. I will gain A(x1,y1) and B(x2,y2) coordinates. need

I am using a single-dimensional array to simulate a two-dimensional array, due to the performance increase of doing so. The formular for finding the index of where to place the item is the following, when the height of the array is 30 items, and the

First of all this is more of a math question than it is a coding one, so please be patient. I am trying to figure out an algorithm to calculate the mean for a set of numbers. However I need to neglect any numbers that are not close to the majority of

Hey all, I am a total newbie developing an android application, I've been reading 'Sams Teach Yourself Java in 24 hours' and it's a great book. But I have been stuck on a bit where I get the value of a decimal number only editTexts and use java maths

I have a rotation quaternion and want to extract the angle of rotation about the Up axis (the yaw). I am using XNA and as far as I can tell there is no inbuilt function for this. What is the best way to do this? Thanks for any help, VenatuThe quatern

I'm searching the way to efficiently find the point on an edge which is the closest point to some other point. Let's say I know two points which are vertices of the edge. I can calculate the equation of the line that crosses those points. What is the

I've got a number of controls (charts in this case) that's determined at runtime. I'd like to put these in a grid with the proper number of rows and columns. For example, 4 items = 2 x 2 8 items = 4 x 2 9 items = 3 x 3 20 items = 5 x 4 11 items = 4 x

I am trying to use the sinf function in my C Program but it gives me an undefined reference error under MSVC 6.0, however sin works fine. This make me curious to find the difference between sin and sinf. What is the logical difference between sin and

I'm using .net WPF geometry classes to graph waveforms. I've been using the matrix transformations to convert from the screen coordinate space to my coordinate space for the waveform. Everything works great and it's really simple to keep track of my

(Also posted on the MSDN forum - but that doesn't get much traffic, as far as I can see.) I've been trying to provide an example of Assert and Assume. Here's the code I've got: public static int RollDice(Random rng) { Contract.Ensures(Contract.Result

I'm trying to put together an app for fun that has a scenario where I need to figure out a probability equation for the following scenario: Suppose I have a number of attempts at something and each attempt has a success rate (known ahead of time). Wh

I'm building, for example, an application that monitors your health. Each day, you're jogging and doing push-ups and you enter the information on a web site. What I would like to do is building a chart combining the hours you jogged and the number of

I'm looking for an online tool that will let me create a gif or png like this one: Some kind of LaTex online service, with friendly examples?I use Roger's Online Equation Editor. PNG, colors, transparent background and anti-aliasing are all included.