Напишите С# на языке джава
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.Write(«a=»);
double a=Convert.ToDouble(Console.ReadLine());
Console.Write(«n=»);
int n = Convert.ToInt32(Console.ReadLine());
double a2=1;
double summ=1;
for (int i =2; i<=n; ++i){
a2*=a;
summ +=a2;
}
Console.WriteLine("summ="+summ);
Console.ReadKey();
}
}
}
Answers & Comments
Ответ:
import System;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
Console.Write(a, =);
double a = Convert.ToDouble(Console.ReadLine());
Console.Write(n, =);
int n = Convert.ToInt32(Console.ReadLine());
double a2 = 1;
double summ = 1;
for (int i = 2; (i <= n); i++) {
a2 = (a2 * a);
summ = (summ + a2);
}
Console.WriteLine(("summ=" + summ));
Console.ReadKey();
}
}
}