learning C at the momment using sams teach yourself C. finished week one and I tried writing a program to find the first 100 prime numbers.
as you can see I ended up writing a rediculiously long while condition to see if there wasn't a modulus between the variable numb and any listing in the array ar[100]. how can a write a while condition that is more compact but follows the same logical routine as what I have so far?
and is the code listed between lines 20- 23 required? figured that i would get errors with !(numb%0)||, didn't try running the program without it though.
yea, thats not working. There are other logical ways of finding prime numbers, but when following this logical path I don't think there is a easy way around it. I think it would be easier to just write a program to write the condition if you needed to work with a large array, like ar[5000] or something. I wonder how big a condtion can be, i guess your only inhibited by system memory.
verbatum the code sugested enters into a infinite loop reguardless of the initial state of divisable. when I tinkered with it I could get it too count up incrementaly 2- 102, then 2, 5, 7 8,9,10..... 100andsomething.