Write a program to find the sum of factorial of all non prime numbers between M and N. for example, if there are 1, 4, 6 and 8 non prime numbers between 1 and 8, then 1! + 4! + 6! + 8! = 41065
Note that the number should not be too large
int IsPrime(int n)
{
int i;
if (n == 1)
{
return 0;
}
for (i = 2; i < n; i++)
{
if (n % i == 0)
{
return 0;
}
}
return 1;
}
int JieCheng(int n)
{
int i,s = 1;
for (i = 1; i
RELATED INFORMATIONS
- 1. It is proved that the factorial of n is not a complete square number (n > = 2)
- 2. A summation of factorial sequence If s = 1 * 1! + 2 * 2!. + 2007 * 2007! Then the remainder of s divided by 2008 is A 0 B 1 C 1004 D2007 Process detailed bonus No process, no points...
- 3. Using java to calculate the factorial of 1 and add it to the factorial of 20. What's wrong with me, //Calculate + 2! + +20!. program name: X03_ 06 For.java public class X03_ 06For{ public static void main(String args[]){ int sum=0,n,m,a=1; for(n=1;n
- 4. VB sum, sin (x) = x / 1-x ^ 3 / 3! + x ^ 5 / 5! - (- 1) ^ (n-1) * x ^ (2 * n-1) / (2n-1)! Exclamation mark means factorial Private Sub Form_ Click() Dim x%,,i%,q% X = Val (InputBox ("please enter the value of X")) Do While t >= 10 ^ (-5) s = s + t n = n + 1 For k = 1 To 2 * n - 1 q = q * k Next k t = ((-1) ^ (n - 1)) * (x ^ (2 * n - 1)) \ q Loop Print "s="; s End Sub It ends when the value of the nth item is less than 10 ^ - 5
- 5. 1 times 2 times 3 is recorded as 3! And read as the factorial of 3. Equal to 1 times 2 times 3 times 4 times 5 times 6 times 7 times 8, equal to 40320. Equal to 10! Equal to?
- 6. Given that the 8N power of 3 = 2, find the - n-1 power of 9 times the - 2n power of 27
- 7. Can you use the rules in the range of rational numbers to illustrate the absolute value of irrational numbers, the reciprocal of irrational numbers, and the fact that two irrational numbers are opposite to each other?
- 8. It is known that a is a rational number, B and C are irrational numbers. Which of the following numbers must be irrational? Which are not? Which are not If it must be, please explain the reason; if not, please give an example. (1)a+b;(2)ab;(3)b+c;(4)bc
- 9. In real numbers, there are__ ① The largest rational number, the smallest irrational number, the number with the largest absolute value, and the number with the smallest absolute value
- 10. Does an irrational number have the smallest absolute value
- 11. Is 2010 factorial + 1 prime? 2! + 1 = 3 is prime 3! + 1 = 7 is prime 4! + 1 = 25 = 5 × 5 is not prime 5! + 1 = 121 = 11 × 11 is not prime 6! + 1 = 721 = 7 × 103 is not prime 7! + 1 = 5041 = 71 × 71 is not prime 8! + 1 = 40321 = 61 × 661 is not prime
- 12. Let n be a natural number, n! = 1 * 2 * 3 *... * (n-1) * n be called the factorial of N, and 0! = 1. Try to write a program to calculate 2, 4, 10! And output the result This problem is java programming!
- 13. 2 4 7 13 factorial calculation 24
- 14. What is the sum of the factorials of 4 and 5? What is the sum of factorials? My question is: what is the sum of factorials of 1-4, and what is the sum of factorials of 1-5?
- 15. 40-32 △ 2 is the factorial of 4
- 16. Prove 1p1 + 2 * (2P2) + 3 * (3p3) +. + n * (NPN) = (n + 1) P (n + 1) - 1
- 17. Now there are seven kinds of gifts, which are simply divided into first class, second class Seventh class It is stipulated that five equal gifts can be exchanged for one higher class gift (five first class gifts can be exchanged for one second class gift; five second class gifts can be exchanged for one third class gift...) But every time you change it, you have to charge 11000 Ask someone if they have enough first class gifts If he wants to exchange a second-class gift, how many first-class gifts do he need? How many times? How much is the handling charge? If he wants to exchange a third-class gift, how many first-class gifts do he need? How many times? How much is the handling charge? If he wants to exchange a fourth-class gift, how many first-class gifts do he need? How many times? How much is the handling charge? If he wants to exchange a fifth class gift, how many first class gifts do he need? How many times? How much is the handling charge? If he wants to exchange a sixth class gift, how many first class gifts do he need? How many times? How much is the handling charge? If he wants to exchange a seventh class gift, how many first class gifts do he need? How many times? How much is the handling charge? Can you provide it
- 18. Why do mathematicians stipulate that the factorial of 0 is 1?
- 19. double fact(int n) { if (n==0) return 1; else return n*(fact(n-1)); }
- 20. If a single variable polynomial is represented by a circularly linked list, try to write a function Calc (x) to calculate the value of the polynomial at X #include //#include using namespace std; class polynomial { public: float coef; int exp; polynomial *next; //void count(polynomial *p,int x); }; int main() { void count(polynomial *p,int x); // string str; polynomial *p; p=new polynomial; int e; float c; polynomial *q,*r; q=p; r=p; // coutexp=e; r->next=q; r=q; } // cout>x; count(p,x); return 0; } void count(polynomial *p,int x) { float c; int e; int f=1; float num=0; polynomial *k,*m; k=p; m=p; while(k!=m) { c=k->coef; e=k->exp; p=k->next; k=p; if(e>=1) { for(e;e>0;e--) { f=x*f; num+=c*f; } f=1; } if(e==0) num+=c; if(e