Created
September 25, 2012 22:32
-
-
Save psykzz/3784871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// p91e2 | |
// | |
// Created by David Gardiner on 25/09/2012. | |
// Copyright (c) 2012 David Gardiner. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
int n, triangularNumber; | |
NSLog(@"Table of triangular numbers"); | |
NSLog(@" N Triangular Number"); | |
NSLog(@"--- -------------------"); | |
triangularNumber = 0; | |
for ( n = 1; n <= 50; ++n) | |
{ | |
triangularNumber += n; | |
if ((n%5)==0) { | |
NSLog(@" %2i %3i",n ,triangularNumber); | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment