Read the characters one at a time, and write an "if" for each of the cases. In each case, if the condition is fulfilled, increment the corresponding counter variable.
The PEC must be 8 digits ending in a letter.
5050, according to the program I quickly whipped up.
no thanks
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
Good luck. I don't think it is possible, since there is no such thing called upper case digits.
It is claimed that pi, to 39 digits provides a level of accuracy sufficient to "draw" a circle the size of a hydrogen atom at the far end of the known universe. However, few cosmological constants are known t anything approaching that level of accuracy.
-- If you accept 4-digit numbers with 'zero' as the first digit, thenthere are 24 possibilities, and their sum is 119,988 .-- If the first digit can't be a 'zero', then there are 18 possibilities,and their sum is 115,992 .Note: I didn't repeat any digits.-- If you allow repeated digits, and accept leading zeros, then there are 256 possibilities,and their sum is 1,279,872.-- If you allow repeated digits but not leading zeros, then there are only 192 possibilities,and their sum is 1,247,904.
The tricky part is getting the individual digits. There are basically two ways to do this: 1) Convert the number to a string, and use string manipulation to get the individual digits. 2) Repeatedly divide the number by 10. The digit is the remainder (use the "%" operator). To actually get the highest digit, initially assume that the highest digit is zero (store this to a variable, called "maxDigit" or something similar). If you find a higher digit, replace maxDigit by that.
#include <stdio.h> int main(int argc, char **argv) { if (argc<1) { printf("Usage: %s number\n",argv[0]); return -1; } int digits=1, i=atoi(argv[1]); while (i/=10) ++digits; printf("%d\n",digits); }
There is a computer program that will print out the value of pi to even more decimal places than that.
There are many shell programs that will find the sum of the square of individual digits of a number. A small example is: SD=3n=2, sum=2, and SD=2.
Partial answers: PiFast by Xavier Gourdon was the fastest program for Microsoft Windows in 2003. According to its author, it can compute one million digits in 3.5 seconds on a 2.4 GHz Pentium 4 But I doubt if the next 999 million digits would take just 999 times as long ( about one hour) the time probably increases exponentially.Super PI by Kanada Laboratory in the University of Tokyo is the program for Microsoft Windows for runs from 16,000 to 33,550,000 digits. It can compute one million digits in 40 minutes and two million digits in 90 minutes and four million digits in 220 minutes on a Pentium 90 MHz.