Pages

viernes, 25 de enero de 2013

Calcular la sumatoria de las N potencias impares Codigo Fuente en Visual Basic

Problema
Hacer un programa o algoritmo, que dado Dado N y X calcular: x1/1+x3/3+x5/5+...+x(2n)-1/(2n)-1

Codigo Fuente en Visual Basic
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim sum As Double = 0.0
        Dim ope, fff As Double
        Dim x As Integer
        Dim n As Integer
        Dim impar As Double
        n = TextBox1.Text
        x = TextBox3.Text
        For i As Integer = 1 To n
            impar = (2 * i) - 1
            sum = sum + (Math.Pow(x, impar)) / impar
        Next i
        TextBox2.Text = Trim(sum)
    End Sub
End Class

0 comentarios:

Publicar un comentario