fork download
  1. #include <stdio.h>
  2. int sum(int n);
  3. int main(){
  4. int n,p;
  5. printf("enter the num: \n"); scanf("%d",&n);
  6. p=sum(n);
  7. printf("%d",p);
  8. return 0;
  9. }
  10. int sum(int n){
  11. int i,res=0;
  12. for(i=1;i<=n;i++){
  13. if(i%3 !=0 && i%5 !=0){
  14.  
  15. res+=i;
  16. }
  17. }
  18. return res;
  19. }
  20.  
Success #stdin #stdout 0.01s 5308KB
stdin
45
stdout
enter the num: 
540