Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* test.cpp */
- #include <iostream>
- template <unsigned long N> struct Sum { enum { value = ((N%3)&&(N%5)?0:N) + Sum<N - 1>::value };};
- template <> struct Sum<0> { enum { value = 0 };};
- int main(){
- for(unsigned int j=0;j<10000;j++){
- unsigned long int x = Sum<10000>::value;
- std::cout<<x<<"\n";
- }
- return 0;
- }
- /* test2.cpp */
- #include <iostream>
- int main()
- {
- for(unsigned int j=0;j<10000;j++){
- unsigned long int sum=0;for(int i=0;i<10000;i++)if((i%3==0)||(i%5==0))sum+=i;
- std::cout<<sum<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment