We use cookies to personalise content and advertisements and to analyse access to our website. Furthermore, our partners for online advertising receive pseudonymised information about your use of our website. cookie policy and privacy policy.

What is the sum of the ODD digits in the first 1,000 digits of "e", or Euler's number, and their count, including the first "2"? Thank you for any help or hints.

 Nov 3, 2019

You didn't say what language are you using in your class project? Here is a short code in C++, but you can easily write the code similarly in any language. The % symbol stands for "mod".

n=?;s=0;p=0;cycle: if(n%10)%2==1, goto4, goto6);s=s+(n%10);p=p+1;n=int(n/10);if(n!=0, goto cycle,0);print"Total Sum =",s;print"Total Num =",p

1 - First, you have to print 1,000 digits of e from whatever source you want.
2 - You would copy and paste that 1,000 digits under "n" in the code above. The conditional statement: if(n%10)%2==1, sums up the odd digits only. If you wish to sum up the even digits, then change the "1" to "0" in the above conditional statement.

Sum total of all odd digits in the first 1,000 digits of e= 2,549
Total Num = 501
And for your own curiosity, the sum total of all even digits =2010
Total Num =499

Notice that the total number of odds + evens =1,000. Now, since the digits are supposed to be "random", you would expect the total of the "odds" to be very close to the total of "evens". Why is there such a big gap? I will leave that question for you to answer !!.

 Nov 3, 2019

7 Online Users