0

Шахматы! Heeelp!Did you play chess?

The grain problem on a chessboard is a mathematical problem that calculates how many grains there will be on a chessboard if you put twice as many grains on each subsequent square of the chessboard as on the previous one, starting with one. To solve this problem, consider that the Board has 64 cells. When doubling the number of grains on each subsequent cell, the sum of grains on all 64 cells is determined by the expression {\displaystyle T_{64}=1+2+4+\cdots +2^{63}=\sum _{i=0}^{63}2^{i}=2^{64}-1,} which is 18 446 744 073 709 551 615 PLEASE,WRITE THIS PROGRAMM IN PYTHON! Задача о зёрнах на шахматной доске — математическая задача, в которой вычисляется, сколько будет зёрен на шахматной доске, если класть на каждую следующую клетку доски вдвое больше зёрен, чем на предыдущую, начиная с одного. Для её решения учтём, что доска имеет 64 клетки. При удвоении количества зёрен на каждой последующей клетке сумма зёрен на всех 64 клетках определяется выражением {\displaystyle T_{64}=1+2+4+\cdots +2^{63}=\sum _{i=0

9th Nov 2018, 3:51 PM
Sara H
Sara H - avatar
10 Answers
+ 6
Where is your attempt???
9th Nov 2018, 3:57 PM
KrOW
KrOW - avatar
+ 8
Nice! It wasn't that hard, was it? You can even do it in one line: print(sum(2**i for i in range(64))) We usually don't write full codes for others because people often ask for quick solutions for their homework. Users are encouraged to learn the language and try to solve the problems themselves. When they get stuck, we're more than happy to help out! Hope you understand :)
9th Nov 2018, 4:56 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
program pr3; uses crt; var k, sum, a: extended; begin clrscr; sum:=0; k:=1; a:=1; while k<=64 do begin sum:= sum+a; a:=a*2; k:=k+1; end; writeln('sum=', sum:25:0); readln; end.Program Zerno; uses crt; Var s,k:extended; i:byte; Const n=64; Begin s:=1; clrscr; for i:=1 to n-1 do Begin k:=exp(i*ln(2)); s:=s+k; End; Writeln('Zerna: ',s:25:0,' shtuk'); Readln;
9th Nov 2018, 4:22 PM
Sara H
Sara H - avatar
+ 1
Kishalaya Saha I could not have said better 😉
9th Nov 2018, 6:54 PM
KrOW
KrOW - avatar
0
my attempt is written in Pascal. I don't know how to write it in Python
9th Nov 2018, 4:17 PM
Sara H
Sara H - avatar
0
Post it and explain what you dont know for convert it in python
9th Nov 2018, 4:22 PM
KrOW
KrOW - avatar
0
Эхх
9th Nov 2018, 4:27 PM
Sara H
Sara H - avatar
0
Where you have difficulty to "convert" to python?
9th Nov 2018, 4:35 PM
KrOW
KrOW - avatar
0
you don't know how to write this program either? If you know , write at least the first couple of rows. I do not understand how to get the sum of degrees 2 in Python ,and the steppes must be 64
9th Nov 2018, 4:43 PM
Sara H
Sara H - avatar