Hi
this is a factorial method but it prints 0 in the console please help me thanks
public class Demo {
public static void main(String[] args) {
Demo obj = new Demo();
System.out.println(obj.factorial(500));
}
public int factorial(int n) {
int fact = 1;
for (int i = 2; i <= n; i++) {
...
Hi,
I'm having trouble solving a simple maths problem. My algebra skills are pretty embaressing.
I've programmed a volume slider to give me a decibel gain value.
db_gain=(x * (8 / 5)) - 90;
For the above I know what x is (the slider thumb position) and I use it to find the db_gain.
How can I switch this around so that given the db_g...
The function a = 2 ^ b can quickly be calculated for any b by doing a = 1 << b.
What about the other way round, getting the value of b for any given a? It should be relatively fast, so logs are out of the question. Anything that's not O(1) is also bad.
I'd be happy with can't be done too if its simply not possible to do without logs or ...
Hi All
Given any two points on compass (Start range and End Range) to form a range. Example from 270(Start range) degrees to 45(End range)degrees and given another point say 7 , how can I work out if that point is between Start and End range ?
I'm trying to write some code to work out if the Wind (in the above point 3) is blowing from...
Possible Duplicate:
Can we solve this using matlab
For the matrix alpha described below, write a script to perform the following computations. Use a complete sentence to describe every number you display. Only use the fprintf() function for displaying answers.
*Compute and display the maximum and minimum values in alpha.
*C...
We currently have a crude mechanism to convert numbers to words (e.g. using a few static arrays) and based on the size of the number translating that into an english text. But we are running into issues for numbers which are huge.
10183 = Ten thousand one hundred eighty three
90 = Ninety
5888 = Five thousand eight hundred eighty eight
...
I was surfing the net looking for a nice effect for turning pages on Android and there just doesn't seem to be one. Since I'm learning the platform it seemed like a nice thing to be able to do is this.
I managed to find a page here: http://wdnuon.blogspot.com/2010/05/implementing-ibooks-page-curling-using.html
- (void)deform
{
Vertex...
Does a 3D vector differ from a 3D point tuple (x,y,z) in the context of 3D game mathematics?
If they are different, then how do I calculate a vector given a 3d point?
...
Hello, i have NP hard problem. Let imagine I have found some polynomial algorithm that find ONLY one of many existing solutions of that problem, but at least one solution (if present in the probem). Is that algorithm considered as solution of NP=P question (if that algorithm transformed to mathematical proof)?
Thanks for answers
...
8B EC 56 8B F4 68 00 70 40 00 FF 15 BC 82 40
A senquence like above can be segmented in various ways,each segment can be translated to corresponding assembly instruction, but each binary executable has its only DEFINITE assembly ,what's the mathematical principle that avoids ambiguity?
UPDATE
The answer with most votes doesn't act...
I'm trying to solve the following real-life problem you might have encountered yourselves:
You had dinner with some friends and you all agreed to split the bill evenly. Except that when the bill finally arrives, you find out not everyone has enough cash on them (if any, cheap bastards).
So, some of you pays more than others... Afterwa...
Hi guys,
i'm tring to understand the Audio * things for iPhone
currently i'm reading: core audio overview
here i got a question:
from apple example codes:
- (void) calculateSizesFor: (Float64) seconds {
UInt32 maxPacketSize;
UInt32 propertySize = sizeof (maxPacketSize);
AudioFileGetProperty (
audioFileID,
...
Possible Duplicate:
How to convert an IPv4 address into a integer in C#?
I'm trying to take strings that are IPv4 IP addresses and convert them to their numeric equivalents.
Is this correct?
var segments = ipV4Address.split('.');
var ipV4AddressAsNumber =
Int64.Parse(segments[0]) * 16777216 + /* octet1 * 256*256*256 +...
Given two random integer generators one that generates between 1 and 7 and another that generates between 1 and 5, how do you make a random integer generator that generates between 1 and 13? I have tried solving this question in various ways but I have not been able to come up with a solution that generates numbers from 1 to 13 with equa...
Today I had my algorithms quiz for the semester and I can't figure out these two questions and they've been bugging me all day. I've gone through my notes and the lecture notes and I'm still unsure. I would appreciate it if someone could take a look and provide some insight into these questions. These are not homework and I've already sa...
Suppose we have a connected and undirected graph: G=(V,E).
Definition of connected-set: a group of points belonging to V of G forms a valid connected-set iff every point in this group is within T-1 edges away from any other point in the same group, T is the number of points in the group.
Pls note that a connected set is just a connec...
I want to display like example 1e10 to 10^10 in JLabel, the ^10 become small size.
...
In the Communications of the ACM, August 2008 "Puzzled" column, Peter Winkler asked the following question:
On the table before us are 10 dots,
and in our pocket are 10 $1 coins.
Prove the coins can be placed on the
table (no two overlapping) in such a
way that all dots are covered. Figure
2 shows a valid placement of the c...
According to http://www.html5samples.com/2010/03/html-5-canvas-the-2d-context-part-1/
This is the signature for the context.transform method
context.transform(m11, m12, m21, m22, dx, dy) is to multiply the current transformation matrix with the matrix described by:
m11 m21 dx
m12 m22 dy
0 0 1
I am trying to figure out what is t...
I have been looking at various programming problems and algorithms in an effort to improve my programming and problem solving skills. But, I keep running into description like this one:
"Let A = [a1,a2,...,an] be a permutation of integers 1,2,...,n. A pair of indices (i,j), 1<=i<=j<=n, is an inversion of the permutation A if ai>aj. We a...