package shin.m; import java.util.Scanner; public class Kakuritsun { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.print("試したい最大のNを入力 : N = "); int N = s.nextInt(); s.close(); System.out.println("n = 4から" + N + "まで"); for(int i = 4;i <= N;i++){ if(i % 2 == 1){ System.out.println("n = " + i + "で終わる確率 : 0"); }else{ int t = i / 2; double p = ((4 * Math.sqrt(5))/(15 * 27 * Math.pow(9, t-2))) * ((2 + 2 * Math.sqrt(5)) * Math.pow((3 + Math.sqrt(5)), t-2) - (2 - 2 * Math.sqrt(5)) * Math.pow((3 - Math.sqrt(5)), t-2)); System.out.print("n = " + i + "で終わる確率 : " + p); System.out.println(" " + Math.pow(2, i) + "/" + Math.pow(3, i) + " = " + Math.pow(2.0/3.0, i)); } } } }