Click here to Skip to main content
15,891,607 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Midi_Mick6-Feb-17 1:44
professionalMidi_Mick6-Feb-17 1:44 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Kornfeld Eliyahu Peter6-Feb-17 2:06
professionalKornfeld Eliyahu Peter6-Feb-17 2:06 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Bassam Abdul-Baki6-Feb-17 2:01
professionalBassam Abdul-Baki6-Feb-17 2:01 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Kornfeld Eliyahu Peter6-Feb-17 2:04
professionalKornfeld Eliyahu Peter6-Feb-17 2:04 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Bassam Abdul-Baki6-Feb-17 2:41
professionalBassam Abdul-Baki6-Feb-17 2:41 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Kornfeld Eliyahu Peter6-Feb-17 2:49
professionalKornfeld Eliyahu Peter6-Feb-17 2:49 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Bassam Abdul-Baki6-Feb-17 2:42
professionalBassam Abdul-Baki6-Feb-17 2:42 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Midi_Mick6-Feb-17 2:08
professionalMidi_Mick6-Feb-17 2:08 
Actually, wrote a small program to demonstrate:

C#
namespace TestJumps {
	class Program {
		static void Main(string[] args) {
			string s;
			do {
				double d;
				Console.Write("Input test value: ");
				s = Console.ReadLine();
				if (double.TryParse(s, out d) && d > .5D) {
					int i = 0;
					double total = d;
					while (total < 1D) {
						d /= 2;
						total += d;
						i++;
					}
					Console.WriteLine("Total {0} reached in {1} steps", total, i);
				}
			} while (!string.IsNullOrEmpty(s));
		}
	}
}


Results:
Input test value: .51
Total 1.0040625 reached in 5 steps
Input test value: .501
Total 1.00004296875 reached in 8 steps
Input test value: .500000001
Total 1.00000000013735 reached in 28 steps
Cheers,

Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Kornfeld Eliyahu Peter6-Feb-17 2:22
professionalKornfeld Eliyahu Peter6-Feb-17 2:22 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Midi_Mick6-Feb-17 2:47
professionalMidi_Mick6-Feb-17 2:47 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Kornfeld Eliyahu Peter6-Feb-17 2:54
professionalKornfeld Eliyahu Peter6-Feb-17 2:54 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Daniel Pfeffer6-Feb-17 3:12
professionalDaniel Pfeffer6-Feb-17 3:12 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Midi_Mick6-Feb-17 3:22
professionalMidi_Mick6-Feb-17 3:22 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
OriginalGriff6-Feb-17 1:59
mveOriginalGriff6-Feb-17 1:59 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
lopatir6-Feb-17 0:57
lopatir6-Feb-17 0:57 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
OriginalGriff6-Feb-17 1:59
mveOriginalGriff6-Feb-17 1:59 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
lopatir6-Feb-17 3:55
lopatir6-Feb-17 3:55 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Marc Clifton6-Feb-17 2:10
mvaMarc Clifton6-Feb-17 2:10 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Kornfeld Eliyahu Peter6-Feb-17 2:26
professionalKornfeld Eliyahu Peter6-Feb-17 2:26 
GeneralRe: TWCP OTD (The Who Cares Puzzle Of The Day) - 6th of February, 2017 Pin
Mark_Wallace6-Feb-17 3:49
Mark_Wallace6-Feb-17 3:49 
GeneralWSO CCC 6/2/17 Pin
PeejayAdams5-Feb-17 22:11
PeejayAdams5-Feb-17 22:11 
GeneralRe: WSO CCC 6/2/17 Pin
LabVIEWstuff5-Feb-17 22:31
LabVIEWstuff5-Feb-17 22:31 
GeneralRe: WSO CCC 6/2/17 - WINNER Pin
PeejayAdams5-Feb-17 22:43
PeejayAdams5-Feb-17 22:43 
GeneralRe: WSO CCC 6/2/17 - WINNER Pin
LabVIEWstuff6-Feb-17 2:09
LabVIEWstuff6-Feb-17 2:09 
GeneralRe: WSO CCC 6/2/17 - WINNER Pin
PeejayAdams6-Feb-17 2:47
PeejayAdams6-Feb-17 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.