Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int eh_primo (int y)
- {
- int i = 2, p = 0;
- while (y > i){
- if (y%i == 0){
- p = p + 1;
- }
- i++;
- }
- proximo_primo(p, y);
- }
- int proximo_primo (int p, int y)
- {
- if(p == 0){
- return y;
- }
- else{
- y = y + 1;
- eh_primo(y);
- }
- }
- double fatorial (int z, int i)
- {
- double fat = 1, total;
- while(z > 1){
- fat = fat * z;
- z--;
- }
- fat = fat/i;
- return fat;
- }
- int main ()
- {
- int n, i = 1, y;
- double t = 0, v = 0;
- scanf("%d", &n);
- while(n >= i){
- y = (n+i) - n;
- printf("%d!/%d", i, eh_primo (y));
- if(n > i){
- printf(" + ");
- }
- t = fatorial(i, eh_primo (y));
- v = v + t;
- if(n == i){
- printf("\n");
- }
- i++;
- }
- printf("%.2lf\n", v);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement