int sum = 0;
int i;
int j = 1;
while(true){
if(i = 1000){
goto END;
}
i = i + 1;
if(i % 3 == 0 && i % 5 == 0){
sum = sum + 1;
}
}
END:
puts(sum);
Am I EXPERT yet?
Name:
Anonymous2014-03-05 0:12
[code]#include <cstdlib>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <time.h>
#include <math.h>
using namespace std;
#ifndef FIVE
#define FIVE 5
#endif
#ifndef THREE
#define THREE 3
#endif
int main(){vector<int> threes; vector<int> fives; int three=0; int five=0;
bool keep3= true, keep5= true;
int sum =0; int lastnumb=0;
for(;;;){
three+=THREE;
five+=FIVE;
keep3 = (three>=1000)? false : keep3;
keep5 = (five<1000)? keep5 : false;
if(keep3)threes.push_back(three);
if(keep5)fives.push_back(five);
I MENA #include <cstdlib>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <time.h>
#include <math.h>
using namespace std;
#ifndef FIVE
#define FIVE 5
#endif
#ifndef THREE
#define THREE 3
#endif
int main(){vector<int> threes; vector<int> fives; int three=0; int five=0;
bool keep3= true, keep5= true;
int sum =0; int lastnumb=0;
for(;;;){
three+=THREE;
five+=FIVE;
keep3 = (three>=1000)? false : keep3;
keep5 = (five<1000)? keep5 : false;
if(keep3)threes.push_back(three);
if(keep5)fives.push_back(five);
>>13
Yes, I am a pedophile. So? I dont see any problem. I embraced my childlover soul long ago and I am happy together with my girlfriend (who is a cute 6 y/o loli!). We fuck a lot of her friends with and without their consent and I am pretty slim and good looking. But thanks anyway asshole. Go and watch your stupid porn with grown women in it while I have SEX with my underaged girlfriend.
sum = 0
for i in range(1, 1000):
if (i%3 == 0)and(i%5 == 0):
sum = sum + i
print(i)
elif i%5 == 0:
sum = sum + i
print(i)
elif i%3 == 0:
sum = sum + i
print(i)
print sum
Name:
Anonymous2014-03-06 11:14
>>21
Even better:
int i=0,sum=0;
for(;i<1000;i++)if(!(i%15))sum+=i;
Name:
Anonymous2014-03-06 14:42
why don't you do it the easy way?
s = sum [x | x <- [0..1000], x `mod` 3 == 0, x `mod` 5 == 0]
main = print s
Name:
Anonymous2014-03-06 18:57
>>28 sum [x | x <- [0..1000], x `mod` 3 == 0 || x `mod` 5 == 0]
I think OP actually wants the sum of all multiples of 3 and/or 5 that are less than 1000, not all multiples of both 3 and 5, otherwise he would have probably said multiples of 15.