Demo entry 6339595

ะบัƒั€ั

   

Submitted by anonymous on Dec 22, 2016 at 18:56
Language: C#. Code size: 910 Bytes.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Curse1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Type an X: ");
            double x = Convert.ToDouble(Console.ReadLine());
            double a = Math.Log(1 - x);
            double x1 = 1;
            double b = 0;
            double b1 = 999;
            int n = 0;
            int count_of_iterations = 0;
            while (Math.Abs(b - b1) > 0.000001)
            {
                b1 = b;
                count_of_iterations++;
                x1 = (x1 * x);
                n++;
                b -= x1 / n;
            }
            Console.WriteLine("A = {0} | B = {1}", a, b);
            Console.WriteLine("Count of iterations = {0}", count_of_iterations);
            Console.ReadKey();
        }
    }
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).