Advertisement
nguyenhappy92

Hãy tính tích các chữ số lẻ của số nguyên dương n

Oct 8th, 2015
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. // Hay tinh tich cac chu so le cua so nguyen duong n
  2. // Khai bao ham thu vien
  3.  
  4. #include<stdio.h>
  5. #include<conio.h>
  6.  
  7. void main()
  8. {
  9. int n;
  10. scanf("%d",&n);
  11. long s=1;
  12. if(n==0)
  13. {
  14. printf("0");
  15. }
  16. else
  17. {
  18. for(int i=1;i<=n;i++)
  19. {
  20. if(i%2!=0)
  21. {
  22. s=s*i;
  23. }
  24. }
  25. printf("%ld",s);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement