Bai16

Bai16
 avatar
unknown
java
a year ago
620 B
5
Indexable
import java.util.Scanner;
import java.lang.Math;

public class main{
    static float deQuy(int i, float total){
        return total+i;
    }
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        
        System.out.print("Nhap n");
        int  n= input.nextInt();

        System.out.print("Nhap x");
        int  x= input.nextInt();

        float sum = 0;
        float total = 0;

        for(int i =1; i<=n; i++){
            total = deQuy(i,total);
            sum+=Math.pow(x, i)/total;   
        }
        System.out.println(sum);
    }
}
Editor is loading...
Leave a Comment