/* * bhatt.umang7@gmil.com */ /* * 2520 is the smallest number that can be divided * by each of the numbers from 1 to 10 without any remainder. * What is the smallest positive number that is evenly * divisible by all of the numbers from 1 to 20? */ #include<iostream> using namespace std; int main() { long n1 = 100; int ans1 = 0; int ans2 = 0 ; int ans = 0 ; for(int i = 1 ; i <= n1 ; i++) { ans1 += i; } ans1 = ans1 * ans1; for(int i = 1 ; i <= n1 ; i++) { ans2 += (i*i); } ans = ans1 + ans2; cout<< "Ans is " << ans1-ans2 ; return 0; }
No comments:
Post a Comment