giúp với ạ: Cho một tổng các số tự nhiên từ 1 đến N như sau : ( S = 1 + 2+ 3 +4 +5+....+N )
Tính tổng S khi N = 2000:........
Tính tổng S khi N= 2018:........
Mọi người giúp mình câu này với ạ :
Tính tổng : S= 1-2-3+4+5-6-7+8+9-10-11+12+...+n
Viết chương trình pascal nhập vào một số n tính tổng từ 1 đến n theo 2 cách
cho số tự nhiên N(1 N<10^6). Tính tổng sau : S= 1-2+3-4+5-6...+N
viết chương trình ra giúp vs
uses crt;
var i,n:integer;
s:longint;
begin
clrscr;
write('nhap n:');readln(n);
s:=0;
for i:=1 to n do
if i mod 2=1 then s:=s+i
else s:=s-i;
writeln('s= ',s);
readln;
end.
Cho số tự nhiên S bằng tổng của các số tự nhiên từ 1 đến n;biết nếu lấy S trừ đi một số tự nhiên khác nằm trong khoảng từ 1 đến n thì ta được số mới có giá trị bằng 410.Tính giá trị của S;n?
\(S=410+a\)(1).
Vì \(1\le a\le n\)nên \(1+410\le a+410\le n+410\)\(\Rightarrow411\le S\le410+n\Rightarrow411\le\frac{n\left(n+1\right)}{2}\le410+n\)
\(\Leftrightarrow822\le n\left(n+1\right)\le820+2n\)
\(\Leftrightarrow\hept{\begin{cases}n\left(n+1\right)\ge822\Rightarrow n\ge29\\n\left(n+1\right)\le820+2n\Rightarrow n^2-n\le820\Rightarrow n\left(n-1\right)\le820\Rightarrow n\le29\end{cases}}\)
\(\Rightarrow n=29\).
Và \(S=\frac{29\cdot30}{2}=435\).
Đáp số S=435 ; n= 29Cho chương trình Tính Tổng Các Số Tự Nhiên Từ S=1+2+3+ ...... (Khi Tổng S đầu tiên > 1000 thì dừng). Hỏi cộng bao nhiêu số?
Hãy Tìm lỗi trong chương trình và sửa lỗi viết lại chương trình cho đúng:
Program tinh_tong;
Var n S: Integer
Begin
n: 0;
S = 0;
While S< 1000 do
n:= n + 1;
S:= S + n
Writeln(‘Can cong’,n-1,’so va tong dau tien > 1000 la’, S);
Readln;
End.
Viết ctrinh dưới đây bằng ngôn ngữ lập trình pascal? a)Tính tổng các số lẻ trong phạm vi từ 1 đến N(S=1+3+5+7...+N) b)Tính tổng các số chẵn trong phạm vi từ 1 đến N(S=2+4+6+8...+N c)Tính tích các số chẵn trong phạm vi từ 1 đến N(P=2.4.6...N) d)Tính tích các số lẻ trong phạm vi từ 1 đến N(P=1.3.5...N)
Program HOC24;
var i,n: integer;
S,P: longint;
begin
write('Nhap n: '); readln(n);
{..............................................}
readln
end.
-----------------------------------------------------------
Bạn điền vào {........................} theo từng bài nhé
a) S:=0;
for i:=1 to N do if i mod 2=1 then s:=s+i;
write('S= ',s);
b)
S:=0;
for i:=1 to N do if i mod 2=0 then s:=s+i;
write('S= ',s);
c) P:=1;
for i:=1 to N do if i mod 2=0 then p:=p*i;
write('P= ',p);
d)
P:=1;
for i:=1 to N do if i mod 2=1 then p:=p*i;
write('P= ',p);
1, Cho x thuộc Z thỏa mãn: -2005< x < = 2005
a, Tính tổng các số nguyên x
b, Tính tích các số nguyên x
2, Tính A= -45.58 - 45. 42/ 2+ 4+ 6+ 8+...+ 16+ 18
3, Hiệu của 2 số bằng 0,6. Thương của số nhỏ chia cho số lớn cũng bằng 0,6. Tính 2 số đó
4, a, Cho góc AOB. Trong góc AOB vẽ các tia OC; OD sao cho AOC= BOD. CMR: AOC= BOD
b, Cho tam giác ABC, gọi M là 1 điểm thuộc cạnh AC, gọi E là 1 điểm thuộc cạnh AB. Đường thẳng CE cắt cạnh AB của tam giác ABM. Giari thích vì sao CE cắt AB của tam giác ABM
5,
a, Tìm số tự nhiên n biết tích các c/s của n bằng: n2- 10n- 22
b, Tìm số tự nhiên n biết tổng các c/s của n bằng: S(n)= n2- 2003n+ 5
c, Tìm số tự nhiên n sao cho: n + S(n)+ S(S(n))= 60, với S(n) là tổng các c/s của n
MONG CÁC BẠN GIÚP MIK ĐẾN TRƯỚC HÔM 2/8/2019 NHÉ
bạn Lan tính tổng các số tự nhiên liên tiếp từ 1 đến n và nhận thấy số đó chia hết cho 29. Loan tính tổng các số tự nhiên từ 1 đến m và cũng nhận thấy tổng đó chia hết cho 29. tìm các số tự nhiên m và n thỏa mãn điều kiện m<n<50
giúp mình với ạ
Viết chương trình tính tổng nghịch đảo N số tự nhiên S= 1+1/2+1/3+...+1/N với N được nhập từ bàn phím. (sử dụng câu lệnh lặp for...do hoặc while...do...). Giúp e với ạ
Program HOC24;
var i,n: integer;
S: real;
begin
write('Nhap N: '); readln(n);
s:=0;
for i:=1 to N do s:=s+1/i;
write('S= ',s:5:2);
readln
end.
Câu 2: (2,0 điểm) TÍNH TỔNG
Cho tổng S = 1^2 + 3^2 + 5^2 + ... + (2n – 1)^2 với 𝑛 ∈ 𝑁.
Yêu cầu: Tính tổng S.
Dữ liệu vào: Nhập từ bàn phím số tự nhiên N (0 <n<=10000)
Kết quả: In kết quả tính được của tổng S ra màn hình.
#include <bits/stdc++.h>
using namespace std;
long long s,i,n;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
if (i%2==1) s=s+i*i;
cout<<s;
return 0;
}