Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function real paragontiko(input int m);
- real total;
- total = 1;
- for (int i = 1; i <= m; i++) begin
- total = total * i;
- end
- return total;
- endfunction
- initial begin
- int N=-5;
- real sum, total_sum;
- if(N<=0) begin
- $display("Error, N should be >0",);
- $finish;
- end
- sum=0.0;
- total_sum = 0.0;
- for (int i=1; i<=N; i++) begin
- if(i%2==0) begin
- sum = 1.0/real'(i) - 1.0/paragontiko(i);
- end else begin
- sum = 1.0/real'(i) + 1.0/paragontiko(i);
- end
- $display("sum=%f",sum);
- total_sum = total_sum + sum;
- end
- $display("S=%f",total_sum);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement