Skip to main content
techie summer

the summer season has started, and what a great way to enjoy it than to start hacking (or coding, for the misinformed) on old projects, and new ones as well...

however, to the un-tech savvy people reading this blog, i'm sorry but i would have to get a little technical. first of, i'd like to start with a snippet of code, which i hope would be helpful to you and your endeavors.


#include <math.h>

int isprime(int n) {
int prime=1; /* assume that the number is prime */
int dlimit, dit;

if (n <= 3) /* the first 3 primes */
return prime;

if (!(n % 2)) /* if divisible by 2 (or even) */
prime = 0; /* it's not prime */

dlimit = (int) sqrt ( (double) n); /* result of sqrt is a double */

for (dit = 5; (dit <= dlimit) && (prime); dit+=2)
if (!(n % dit)) /* if divisible by odd numbers */
prime = 0; /* then it's not prime */

return prime;
}


this (as you might notice in the near future) will check whether a number is prime. in my estimation, the running time of this algorithm is O(n^1/2) or [oh of square root of n] where n is the number to be checked for primality.

i came up with this and a few more useful code snippets while i was thinking about and checking on my coding abilities the past few days.

now, i will need to brush up on my programming skills because i think i'm way behind of the pack, and knowing how to code is something, and writing code that actually works is another. i have to got both, but still more work is required. anyway, i hope i have time to do what i love most to do, which is think.

chill! =)

Comments

Popular posts from this blog

Appreciating Rizal...

Nope, this is not an academic post. More of a reflective and wrote-because-i-was-enlightened type post. Anyway, I just passed a paper on Rizal's notion of a nation according to Quibuyen (a local writer who devoted a book -- A Nation Aborted -- on his treatise on Rizal). Chapter 6 was an interesting read, and a definite eye opener. Rizal all of a sudden became interesting, especially to someone like me who could care less. It seems that most of what Rizal aims for and wrote about is still evident in today's Philippines as I see it. I wonder why I didn't get to appreciate Rizal and his work when I was still in high school -- might be the fault of the high school and the curriculum, or might be because I was still considerably immature then. I wasn't able to understand most of Rizal's writings though even if I got to reading them basically because they translated from Spanish to Filipino/Tagalog. I don't have problems with Tagalog, until you put it in writing. I

So much for that...

I just came home from the seminar regarding my proposed load balancing algorithm. I tried to get as candid as I can, but still half of what I said was jargon -- which made me explain the thing in layman's terms and using more colloquial examples. I was wearing a black suit, (chinese collared americana suit that is), gray slacks, black leather belt (perry ellis), and leather shoes (by bristol). I'm beginning to sound like a caption to a fashion mag's pic, but I digress... So there I was, waiting for the seminar to start. As a speaker, I conducted myself properly and tried to get things cleared out with my co-presentors. I was asuuming that they knew at least half of what they were supposed to talk about, and that they knew how to speak in front of a crowd. BUT NO... I sat through two presentors, the first one reading the presentation of the projection, and then doing no explaining whatsoever. I didn't get that because she prepared her own slides, and prepared the hand

Mobility

Everyday, I am getting fascinated more and more by the technology literally in the palm of my hands when I look at and use my cellular phone. Thanks to the ingenuity and vision of the makers of the Sony Ericsson K750i, I enjoy the features that make my life a little more enjoyable and bearable amidst the hectic schedule I have. Like the fact that I can actually access my email from my cellphone using IMAP4+TLS/SSL?! If only it wasn't so darned expensive to access information through the SMART's GPRS network... Anyway, this is how my dad's cellphone looks like (treated at an angle up close and embarassingly personal). I wanted to see how it would turn out treated as a subject in black and white. I don't know why I feel that the omnipotence and omnipresence of anything is best captured using black and white photos. I feel that it preserves the object, but takes out the frills and color otherwise distractions to the scene. I feel that it also allows me to capture what is