How many times does a zero occur on an odometer

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

Binary encryption

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

Calculate exp (x) with the use of Python recursion

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

Why is the exit negative?

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

Find the integral solution of an equation

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

Reduction of rounding error?

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 mpz_powm () without mod

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

Solve the recurrence T (n) = 2T (sqrt (n))

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

Generating a permutation of a string

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

Exponential of very small numbers in python

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

Always have a bad value when adding two numbers

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.

C ++ library for signal processing

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

Find the 3rd point of a line using c ++

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

Coordinate the calculation problem!

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

Four Questions - Calculator Application - Android Java

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

Extraction of the lace of a quaternion

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

Determine the necessary rows / columns based on a number

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

sin v / s sinf function in C

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

Help with the probability equation

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

Construct an array of activities combining two types of data

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

Online tool to generate mathematical equation image files

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.