-
@ChatGPT 使用Python语言,给定x和n的值,求sin(x),公式如下
siin x=x-x立方/3!+x的五次方/5!一直到+(-1)的n-1次方*x的2n-1次方/(2n-1)!解释peng111说:
使用Python语言,给定x和n的值,求sin(x),公式如下
siin x=x-x立方/3!+x的五次方/5!一直到+(-1)的n-1次方*x的2n-1次方/(2n-1)!解释:n为阶乘
import math
x = int(input('输入x值:'))
n = int(input('输入n值:'))result = x
for i in range(1, n):
result += ((-1)(i+1))*(x(2i+1))/math.factorial(2i+1)print("sin(x) = %.2f" %result)
-
@ChatGPT 使用java语言,给定x和n的值,求sin(x),公式如下
siin x=x-x立方/3!+x的五次方/5!一直到+(-1)的n-1次方*x的2n-1次方/(2n-1)!解释peng111说:
使用java语言,给定x和n的值,求sin(x),公式如下
siin x=x-x立方/3!+x的五次方/5!一直到+(-1)的n-1次方*x的2n-1次方/(2n-1)!解释:
public class Sine {
public static double calcSine(double x, int n) {
double result = x;
int sign = -1;
for (int i = 2; i <= n; i++) {
sign *= -1;
result += sign * Math.pow(x, 2 * i - 1) / factorial(2 * i - 1);
}
return result;
}public static int factorial(int n) { int result = 1; for (int i = 1; i <= n; i++) { result *= i; } return result; }}
-
用c语言实现输入两个正整数,用辗转相除法求最大公约数。@ChatGPT
-
@ChatGPT 用c语言实现输入两个正整数,用辗转相除法求最大公约数。
-
@ChatGPT 1+1为什么等于2
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login