Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm wondering about whether an algorith exists for the following:

1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
1.10
1.11
1.12

Is it possible to count like this through means of an algorith?

If Y = 1
And Val = 1.1
And Z = 10

I'm looking for an algorithm e.g.:
X = ((((Val - Y) * Z) + 1) / Z) + Y

But this won't be possible as 1.20 is actually equal to 1.2 so the Val would have to be a string which was what I was trying to avoid.

Thanks,

[EDIT]

I've found my answer thank you.
The algorithm which I was looking for is:

If Y = 1
And Val = 1.1
And Z = 10

X = ((((Val - Y) * Z) + 1) / Z) + Y


However, this won't be possible as 1.20 is equivalent to 1.2 and 1.30 is equivalent to 1.3.
Thus, some form of string manipulation is needed.

C#
double counter = 0;

double remWholeNumber = 1.0;
double addWholeNumber = 1.0;
double firstValueInSeq = 1.1;
double remFraction = 10.0;
double addFraction = 10.0;
double X = 0.0; // initialise
double F = ((firstValueInSeq - remWholeNumber) * remFraction);

for (counter = 0.0; counter < 50.0; counter++)
{
  X = ((F) / addFraction) + addWholeNumber;
  F++;

  // increment counter
  counter++;

  printf("%f\n", X);
}


// Maybe it make sence now?
// I give a zero to all the brainiacs to clever to read the question carefully.
Posted
Updated 13-May-11 2:41am
v6
Comments
Sandeep Mewara 11-May-11 5:09am    
Not clear.
R. Erasmus 11-May-11 5:19am    
Not clear? How much more clearer do you want it?

Do you mean: "Does it exist a finite sequence of logical steps able to reproduce the given sequence?"
Yes, it exists.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-May-11 7:33am    
Great answer, my 5.
Computable, damn it, strange is it!
--SA
R. Erasmus 19-May-11 2:58am    
So it does infact exist, but this case is special in that the steps are infact not logical and therefor not possible because 1.9 + 0.1 = 2.0 and not 1.10 as what was needed.
CPallini 19-May-11 4:16am    
That's because your algorithm isn't aware that the two numbers (the one on the left and the one on the right of the dot) should be handled indipendently.
R. Erasmus 19-May-11 5:06am    
And not only independantly but also shouldn't be handled mathimatically but programmatically instead.
CPallini 19-May-11 5:11am    
>> "shouldn't be handled mathimatically but programmatically instead"
Is there any difference?
Anyway you asked for an algorithm, and I am a programmer, you know.
Even Microsoft Word implements such an algorithm (to number chapters, paragraph,...).
C#
double counter = 0;

double remWholeNumber = 1.0;
double addWholeNumber = 1.0;
double firstValueInSeq = 1.1;
double remFraction = 10.0;
double addFraction = 10.0;
double X = 0.0; // initialise
double F = ((firstValueInSeq - remWholeNumber) * remFraction);

for (counter = 0.0; counter < 50.0; counter++)
{
  X = ((F) / addFraction) + addWholeNumber;
  F++;

  // increment counter
  counter++;

  printf("%f\n", X);
}


NOTE:
This code was derived from the algorith (very much a mathimatical algorithm from where I'm from):
If Y = 1.0
And Val = 1.1
And Z = 10.0

X = ((((Val - Y) * Z) + 1.0) / Z) + Y

This was placed in my previous solution which was deleted.
I was able to accept my own answer. (It looks like a bug to me Code Project)

The answer to my question was that "it cannot be done mathematically however can be done by making use of string manipulation if this algorith were to be used in a computer program."

Why would I say that this is my answer?
Because the sequence value of 1.10 is the equivalent to the value 1.1; When you count sequentially from 1.1 by incrementing 1.1 each time by 0.1, the value after 1.9 would be 2.0 instead of 1.10 which was what I wanted the next sequential value to be.
 
Share this answer
 
v4
It's unclear because we don't know what the algorithm is trying to achieve.
 
Share this answer
 
Comments
R. Erasmus 13-May-11 7:53am    
If my initial value equals 1.1, the value of X should be 1.2 in the first iteration of the loop. The second iteration X should equal 1.3 and so on, up until 1.9999999... But like I said, it will not work and I require to perform some string manipulation for when X Mod 10 = 0. More clear I can't make it.
Joking?
No, such algorithm don't exist :-), because this is not a problem to be discussed seriously.

[EDIT]

I don't understand what are you trying to do with X = ((((Val - Y) * Z) + 1) / Z) + Y.
Recursive formula is V[N] := V[N-1] * 0.1, right?
Nth member is 1.1 + N * 0.1.
The loop code is from 1.1 to [some parameter] step 0.1.
Is there anything else I'm missing?

—SA
 
Share this answer
 
v2
Comments
R. Erasmus 11-May-11 5:00am    
Thought so much, was just trying my luck. :)
R. Erasmus 11-May-11 5:12am    
So I refound some hope that there might be a solution to my problem. Will keep you updated.
Sergey Alexandrovich Kryukov 11-May-11 10:22am    
I do not understand. Do you find it a problem to write one-code-line loop?
--SA
R. Erasmus 12-May-11 2:54am    
I updated my question for you.
Sergey Alexandrovich Kryukov 13-May-11 7:30am    
Now it is not clear. You never mentioned this is string. OK, stop it. If you're still interested, please -- mathematically accurate formulation, with all words, quandors and introduction of all notation. "Let A be a natural number > 1... blah-blah..." could you?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900