using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
public static class Test
{
public static void Main()
{
int max = int.Parse(Console.ReadLine());
double zeta2 = Primes(max).Aggregate(1d, (r, p) => r / (1 - 1d / p / p));
Console.WriteLine(zeta2);
}
private static IEnumerable<int> Primes(int max)
{
if (max < 5)
{
return Enumerable.Range(2, Math.Clamp(max - 1, 0, 2));
}
else
{
return new PrimesCalculator(max).PrimesAsync().Result;
}
}
}
internal sealed class PrimesCalculator
{
internal PrimesCalculator(int max)
{
array = new bool[max + 1];
end = ((int)Math.Sqrt(max) + 2) / 3;
tasks = new List<Task>(end - 1);
removeAction = Remove;
result = Enumerate(array);
}
internal async Task<IEnumerable<int>> PrimesAsync()
{
if (n == 2)
{
RunRemove();
while (n <= end)
{
await Task.Delay(32);
}
await Task.WhenAll(tasks);
}
return result;
}
private static int Generator(int n) => (n & ~1) + (n << 1) - 1;
private static IEnumerable<int> Enumerate(bool[] array)
{
yield return 2;
yield return 3;
int value;
for (int k = 2; (value = Generator(k)) < array.Length; k++)
{
if (!array[value])
{
yield return value;
}
}
}
private readonly bool[] array;
private int n = 2;
private readonly int end;
private readonly List<Task> tasks;
private readonly Action removeAction;
private readonly IEnumerable<int> result;
private void RunRemove()
{
if (n <= end)
{
var task = new Task(removeAction);
tasks.Add(task);
task.Start();
}
}
private void Remove()
{
int prime;
do
{
prime = Generator(n++);
}
while (array[prime]) ;
RunRemove();
ref var isComposite = ref array[prime];
int kDelta = prime << 1;
for (int k = prime * prime; !isComposite && k < array.Length; k += kDelta)
{
array[k] = true;
}
}
}