💻 Hacer un programa que muestre la sumatoria de la serie : 4/2 – 9/1 + 15/1 – 23/2 + 34/8 – 49/64 + ...
VALORES SUPERIORES : 4 – 9 – 15 – 23 – 34 – 49 ...
x = 5
v = 4 + 5 = 9
v = 9 + 6 = 15
v = 15 + 8 = 23
v = 23 + 11 = 34
v = 34 + 15 = 49
Dónde x inicia en 5 : x = (x + 0), (x + 1), (x + 2), (x + 3), (x + 4) ...
VALORES INFERIORES : 2 – 1 – 1 – 2 – 8 – 64 ...
y = 0.5
v = 2 * 0.5 = 1
v = 1 * 1 = 1
v = 1 * 2 = 2
v = 2 * 4 = 8
v = 8 * 8 = 64
Dónde y inicia en 0.5 : y = (0.5 + 0.5), (1 + 1), (2 + 2), (4 + 4), (8 + 8) ...
Algoritmo programacion_work
Definir i, n, sumatoria, v, v1, v2, x, x1, x2 como Real;
Definir ope como Caracter;
sumatoria <- 0;
v <- 4;
v1 <- 5;
v2 <- 1;
x <- 2;
x1 <- 0.5;
ope <- "-";
Escribir "35. MUESTRA SERIE DE NÚMEROS.";
Escribir "";
Escribir Sin Saltar "VALOR DE N : ";
Leer n;
Para i <- 1 Hasta n Con Paso 1 Hacer
Si (i <> n) Entonces
Escribir Sin Saltar v, "/", x, " ",ope, " " ;
SiNo
Escribir Sin Saltar v, "/", x, " ",ope, " ..." ;
FinSi
Si ( (i mod 2) == 1 ) Entonces
ope <- "+";
sumatoria <- sumatoria + (v/x);
SiNo
ope <- "-";
sumatoria <- sumatoria - (v/x);
FinSi
v <- v + v1;
v1 <- v1 + v2;
v2 <- v2 + 1;
x <- x * x1;
x1 <- (x1 + x1);
FinPara
Escribir "";
Escribir "SUMATORIA : ", sumatoria;
FinAlgoritmo
import math
sumatoria = 0
v = 4
v1 = 5
v2 = 1
x = 2
x1 = 0.5
ope="-"
n = int(input("VALOR DE N :"))
for i in range(1,n+1):
if i != n:
print(v,"/",math.trunc(x),"",ope,"",end="")
else:
print(v,"/",math.trunc(x),"",ope,"",end="...")
if (i % 2) == 1:
ope="+"
sumatoria+=(v/x)
else:
ope="-"
sumatoria-=(v / x)
v += v1
v1 += v2
v2 += 1
x *= x1
x1 = x1 + x1
print()
print("SUMATORIA : ", sumatoria)
#include<stdio.h>
#include<string.h>
#define MAX_STRLEN 256
int main() {
float sumatoria=0, v=4, v1=5, v2=1, x=2, x1=0.5, x2=0;
int n;
char ope[MAX_STRLEN];
strcpy(ope,"- ");
printf("VALOR DE N : ");
scanf("%i",&n);
for(int i=1; i<=n; i++){
if(i != n){
printf("%.0f/%.0f %s",v,x,ope);
}else{
printf("%.0f/%.0f %s...",v,x,ope);
}
if( (i%2)==1 ){
strcpy(ope,"+ ");
sumatoria += (v/x);
}else{
strcpy(ope,"- ");
sumatoria -= (v/x);
}
v += v1;
v1 += v2;
v2 += 1;
x *= x1;
x1 = (x1 + x1);
}
printf("\nSUMATORIA : %.2f \n",sumatoria);
return 0;
}
#include<iostream>
using namespace std;
int main() {
double n, sumatoria=0, v=4, v1=5, v2=1, x=2, x1=0.5, x2;
string ope="-";
cout << "VALOR DE N : ";
cin >> n;
for(int i=1; i<=n;i++){
if(i != n){
cout << v << "/" << x << " " << ope << " ";
}else{
cout << v << "/" << x << " " << ope << "...";
}
if( (i%2)==1 ){
ope="+";
sumatoria += (v/x);
}else{
ope="-";
sumatoria -= (v/x);
}
v += v1;
v1 += v2;
v2 += 1;
x *= x1;
x1 = (x1 + x1);
}
cout << endl;
cout << "SUMATORIA : " << sumatoria << endl;
return 0;
}