Could someone show me how to add the numbers 1 thru 50 and display the total of 1275 the easy way. My brain wont close in on this one and I dont want to use a ton of variables.
int result = 0;
for(int i = 0 ; i < 51 ; i ++ )
{
result += i ;
}
thats it...
'result' is 1275
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Originally posted by souldog
sum = (50*51)/2= 25*51
well i alwasys thought...there is a vast difference between experience+coolness and education...
cool Mr.Souldog....expected a cool answer from you like above..
now comes the formula.....cool!!!!
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Bookmarks