Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f9fa8e2
Update White.cs
NemirovichMark Sep 15, 2025
cbc82e3
Update Blue.cs
Ezequiel-A-Zapata Oct 3, 2025
0dedadb
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
b720caa
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
bf333bf
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
e8bcc97
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
c5d9024
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
3073d8b
Update1 Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
a3d5604
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
79c6290
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
1f3f479
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
50d1843
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
edc4580
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
c4c2438
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
fd743ce
Update Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
3659cb7
Update2 Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
3bc4900
Update3 Blue.cs
Ezequiel-A-Zapata Oct 5, 2025
e75d933
Update4 Blue.cs
Ezequiel-A-Zapata Oct 6, 2025
d44d6d0
Update Blue5.cs
Ezequiel-A-Zapata Oct 6, 2025
6a8744d
Update5 Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
3c24d6f
Update GreenTest.cs
Ezequiel-A-Zapata Oct 11, 2025
8264c56
Update PurpleTest.cs
Ezequiel-A-Zapata Oct 11, 2025
d54d58c
Update WhiteTest.cs
Ezequiel-A-Zapata Oct 11, 2025
bf9cbce
Update Green.cs
Ezequiel-A-Zapata Oct 11, 2025
f62eae6
Update Purple.cs
Ezequiel-A-Zapata Oct 11, 2025
549f5d9
Update White.cs
Ezequiel-A-Zapata Oct 11, 2025
b81de27
Update Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
0bb3823
Update Green.cs
Ezequiel-A-Zapata Oct 11, 2025
251df34
Update Purple.cs
Ezequiel-A-Zapata Oct 11, 2025
80388f3
Update White.cs
Ezequiel-A-Zapata Oct 11, 2025
1834963
Update GreenTest.cs
Ezequiel-A-Zapata Oct 11, 2025
b3282dc
Update PurpleTest.cs
Ezequiel-A-Zapata Oct 11, 2025
47e1a0d
Update WhiteTest.cs
Ezequiel-A-Zapata Oct 11, 2025
76f3928
Update7 Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
5bcda1b
Update8 Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
4aa0cdf
Update9 Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
cd22e33
Update10 Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
5c7b00a
Update11 Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
204d15f
Update11 Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
2413721
Update12 Blue.cs
Ezequiel-A-Zapata Oct 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 176 additions & 24 deletions Lab2/Blue.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;

namespace Lab2
Expand All @@ -13,17 +14,33 @@ public double Task1(int n, double x)

// code here

double exp = 1.0;
for (int i = 1; i <= n; i++)
{
double top = Math.Sin(i * x);
answer += top / exp;
exp *= x;
}

// end

return answer;
return answer;
}
public double Task2(int n)
{
double answer = 0;
double answer = 0.0;

// code here
double pow = 1.0; // 5^0
double fact = 1.0; // <-- antes int; evita overflow
int sign = -1; // (-1)^1

// end
for (int i = 1; i <= n; i++)
{
pow *= 5.0; // 5^i
fact *= i; // i!
answer += sign * (pow / fact);
sign *= -1; // alternar signo
}

return answer;
}
Expand All @@ -32,63 +49,198 @@ public long Task3(int n)
long answer = 0;

// code here

if (n <= 0)
{
answer = 0;
}
else
{
long sum = 0;
long a = 0;
long b = 1;

for (int i = 0; i < n; i++)
{
sum += a;
long next = a + b;
a = b;
b = next;
}

answer = sum;
}
// end

return answer;
return answer;
}
public int Task4(int a, int h, int L)
{
int answer = 0;

// code here
int s = 0;
int num = 0;

// end
for (int i = 1; ; i++) // ← quitamos s<L del header
{
int sequence = a + (i - 1) * h;
if (s + sequence > L) break; // ← si me paso, corto

s += sequence;
num++;
}

answer = num;
return answer;
}

public double Task5(double x)
{
double answer = 0;

double answer = 0.0;
// code here

double ch = 0.0, zn = 1.0;
double elem = ch / zn; // 0 al inicio
int i = 1;

do
{
ch += i;
zn *= x;
answer += elem;
elem = ch / zn;
i++;
}
while (elem > 0.0001);
// end

return answer;
}

public int Task6(int h, int S, int L)
{
int answer = 0;

// code here
if (S >= L)
{
return answer;
}
else
{
int initialQuantity = S;
int time = 0;
while (initialQuantity < L)
{
initialQuantity *= 2;
time += h;
}
answer = time;
}

// end

return answer;
}
public (double a, int b, int c) Task7(double S, double I)
{
double r = 1 + I / 100.0;

// a) total en 7 días
double a = 0;
double d = S;
for (int i = 1; i <= 7; i++)
{
a += d;
d *= r;
}

// b) días hasta acumular 100 km (esta suele estar bien)
int b = 0;
int c = 0;

// code here

// end

return (a, b, c);
double acumulado = 0;
d = S;
while (acumulado < 100)
{
acumulado += d;
d *= r;
b++;
}

// c) primer día con distancia diaria > 42 km
// Cambiar aquí: empezar en 0 para coincidir con el test
int c = 0; // <-- antes era 1
d = S;
while (d <= 42)
{
d *= r;
c++;
}

return (a, b, c);
}

public (double SS, double SY) Task8(double a, double b, double h)
{
double SS = 0;
double SY = 0;
double SS = 0.0;
double SY = 0.0;

// code here
if (h <= 0) return (0, 0);

// end
// Iteración por índice entero para cubrir [a, b] de forma robusta
for (int k = 0; ; k++)
{
double x = a + k * h;
if (x > b + 1e-12) break; // incluye b si cae en malla (tolerancia)

// --- Serie S(x) = Σ (2i+1) * x^(2i) / i! ---
double Sx = 0.0;
double q = 1.0; // x^(0)/0! = 1
int i = 0;

while (true)
{
double term = (2 * i + 1) * q;

// Incluir también el primer término con |term| < E y luego cortar
Sx += term;
if (Math.Abs(term) < E) break;

i++;
q *= (x * x) / i; // q_{i+1} = q_i * x^2 / (i)
}

// --- Forma analítica ---
double y = (1 + 2 * x * x) * Math.Exp(x * x);

SS += Sx;
SY += y;
}

return (SS, SY);
}

}
}
}

























4 changes: 3 additions & 1 deletion Lab2/Green.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,6 @@ public int Task7(double L)
return (SS, SY);
}
}
}

}

4 changes: 3 additions & 1 deletion Lab2/Purple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,6 @@ public int Task7(double S, double d)
return (SS, SY);
}
}
}

}

7 changes: 5 additions & 2 deletions Lab2/White.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public int Task5(int L)
public double Task6(double x)
{
double answer = 0;
const double R = 6371.0; // радиус Земли, км

// code here

Expand All @@ -78,6 +77,7 @@ public int Task7(int n)
public int Task8(double L, double v)
{
int answer = 0;
const double R = 6371.0; // радиус Земли, км

// code here

Expand All @@ -86,4 +86,7 @@ public int Task8(double L, double v)
return answer;
}
}
}

}


2 changes: 2 additions & 0 deletions Lab2test/GreenTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,5 @@ public void Test8()
}
}
}


2 changes: 2 additions & 0 deletions Lab2test/PurpleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,5 @@ public void Test8()
}
}
}


2 changes: 2 additions & 0 deletions Lab2test/WhiteTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,5 @@ public void Test8()
}
}
}


Loading