Skip to content

Instantly share code, notes, and snippets.

@RSquaredSoftware
Created March 4, 2014 03:30
Show Gist options
  • Save RSquaredSoftware/9339803 to your computer and use it in GitHub Desktop.
Save RSquaredSoftware/9339803 to your computer and use it in GitHub Desktop.
/*
Dylan Turner
Take Home Quiz, Chapter 5
March 4th, 2014
*/
#include <iostream>
int main()
{
// a(1)
double a = .3;
for (int k = 0; k < 10; k++)
{
// temprary variable for the calculated distance
double distance = 0;
if (k == 0)
{
distance = 0.4;
}
else
{
distance = 0.4 + a;
a = 2 * a;
}
std::cout << "Planet: " << k << " Distance: " << distance << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment