Skip to content

Instantly share code, notes, and snippets.

@WildGenie
Last active November 7, 2019 15:08
Show Gist options
  • Save WildGenie/762e83010330c0e53f0623443e18bd7e to your computer and use it in GitHub Desktop.
Save WildGenie/762e83010330c0e53f0623443e18bd7e to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Text;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
class Solution
{
static void Main(string[] args)
{
long n = int.Parse(Console.ReadLine());
// Write an action using Console.WriteLine()
// To debug: Console.Error.WriteLine("Debug messages...");
for (long divide = 1; divide <= Math.Sqrt(n * n); divide++)
{
if (n * n % divide == 0)
{
long y = n + n * n / divide;
long x = divide + n;
if (x > y) break;
if (x > 0 && y > 0)
Console.WriteLine($"1/{n} = 1/{y} + 1/{x}");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment