Skip to content

Instantly share code, notes, and snippets.

@hu2di
Created April 10, 2017 02:42
Show Gist options
  • Save hu2di/ace7b05aa29649c9e14835d762b9a35b to your computer and use it in GitHub Desktop.
Save hu2di/ace7b05aa29649c9e14835d762b9a35b to your computer and use it in GitHub Desktop.
C-sharp: Convert
int n;
n = int.Parse(Console.ReadLine());
double sum = 0.0;
for (int iCount = 1; iCount <= n; iCount++)
{
sum = sum + 1 / iCount;
}
Console.WriteLine("Ket qua: {0}", sum);
int n;
n = int.Parse(Console.ReadLine());
double sum = 0.0;
for (int iCount = 1; iCount <= n; iCount++)
{
sum = sum + 1 / Convert.ToDouble(iCount);
}
Console.WriteLine("Ket qua: {0}", sum);
int n;
n = int.Parse(Console.ReadLine());
double sum = 0.0;
for (int iCount = 1; iCount <= n; iCount++)
{
sum = sum + 1.0 / iCount;
}
Console.WriteLine("Ket qua: {0}", sum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment