mirror of https://github.com/TheAlgorithms/C
added sol4.c
This commit is contained in:
parent
30364389ef
commit
f4a529eb9a
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
/*An Efficient code to print all the sum of all numbers that are multiples of 3 & 5 below N.*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(){
|
||||
int t;
|
||||
printf("Enter number of times you want to try");
|
||||
scanf("%d",&t);
|
||||
while(t--)
|
||||
{
|
||||
unsigned long long N,p=0,sum=0;
|
||||
printf("Enter the value of N ");
|
||||
|
||||
scanf("%lld",&N); //Take input of N from user
|
||||
for(int i=0;i<N;i++)
|
||||
{
|
||||
if(i%3==0||i%5==0)
|
||||
{
|
||||
sum=sum+i;
|
||||
}
|
||||
}
|
||||
printf("%lld\n", sum); //print the sum of all numbers that are multiples of 3 & 5 below N
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue