private static int[][] fileToPyramid(string path) {
fileStr = File.ReadAllLines(path);
Console.WriteLine(e.Message);
int[][] pyramid = new int[fileStr.Length][];
foreach (string line in fileStr) {
pyramid[i] = Array.ConvertAll(line.Split(' '), int.Parse);
Console.WriteLine(e.Message);
private static bool isPrime(int n) {
for(int i = 2; i <= m; i++)
private static int solve_it(int[][] pyramid, int x, int y, int ret, int res, int length, int stopRet) {
if (isPrime(pyramid[y][x]) == true && stopRet == 0) {
res = solve_it(pyramid, x+1, y, ret, res, length, 1);
if (isPrime(pyramid[y][x]) == true && stopRet == 1){
res = solve_it(pyramid, x, y+1, ret, res, length, 0);
res = solve_it(pyramid, x+1, y, ret, res, length, 1);
private static int[][] sample() {
private static void solve() {
string chooseFile = Console.ReadLine();
if (chooseFile == "test")
path = Console.ReadLine();
pyramid = fileToPyramid(path);
if (pyramid[1] == null) {
Console.WriteLine("RESULT = " + solve_it(pyramid, 0, 1, pyramid[0][0], pyramid[0][0], pyramid.Length, 0));
public static void Main()