Jump to content

Sensei

Senior Members
  • Posts

    7949
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by Sensei

  1. Yesterday, it was too late. OK. Now, I made program in C/C++: #include <stdio.h> //int primes[] = { 2, 3, 5, -1 }; int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, -1 }; bool check(int a, int b) { for (int i = 0; primes[i] > 0; i++) { if ((a % primes[i]) == 0) return(false); if ((b % primes[i]) == 0) return(false); } return(true); } int main(int argc, int *argv[]) { int count = 0; int end = 1; printf("Primes: "); for (int i = 0; primes[i] > 0; i++) { printf("%d ", primes[i]); end *= primes[i]; } printf("\n"); printf("End %d\n", end); int half = end / 2; for (int i = 0; i < half; i++) { int a = i; int b = end - a; if (check(a, b)) { //printf("Found %d %d\n", a, b); count++; } } printf("Count %d\n", count); return(0); } For test case with 3 primes it gave: Which looks good. For OP problem with 9 primes it gave too many results to show them all (so had to disable printf()): 18 mln is over twice more than OP value.
  2. I am surprised by your comment. Mathematics is strict discipline. I was just pointing out that she should say "natural numbers" rather than "numbers". I was just going to say it is not true, but see @joigus already did it for me..
  3. No. You're not correct. There is actually infinite quantity of pairs which summed together will give you other number. e.g. how many pair of numbers will give you 2? 1+1=2 (obvious answer) -1+3=2 (ha!) -2+4=2 etc.etc. Also e.g. rational and irrational numbers can sum to 2.. 0.5+1.5=2 (ha!) 1.9+0.1=2 etc. etc. You didn't specify that only positive integers between 0...N are accepted as answers.. You didn't specify whether 0 is excluded or included in the considerations.
  4. For example?
  5. Amiga has/had bliter to accelerate gfx operations. Bliter has special filling mode for vector graphics. Used in e.g. Another World game to make the main character. SFX also surely was done by DMA not by CPU..
  6. Well, it is good recommendation. But you also have to have constant progress of learning. I think the best progress is during making the real projects. Set pressure on yourself. e.g. one project per week. Instead of downloading ready app from Internet/Google Play Store, write it by yourself. In '80 if you didn't rewrite code in machine code or assembler it was simply too slow, painful or impossible to make other way.. So it made high pressure on programmer to rewrite (and learn machine code in the first place). If anybody wanted to have mouse support in app on my computer, had to write it in machine code. High level language had no support for hardware interrupts, and even if it would have, handling them would be too slow. Programmer had to do it in just a few cycles of CPU. ~1.79 MHz CPU clock and interrupt executed every 57 cycles of cpu at rate ~ 32k per second.. mostly counting down variable to lower frequency than 32 khz... Making it in anything else than machine code would mean stealing the whole processing power of CPU just to handle mouse movements.. Modern computer has DMA, has hardware support for mouse, has hardware support for countless obvious now things. They were novelty 30 years ago. Programmer does not anymore have to deal with it at so low level. But if you would like to have e.g. mouse support on e.g. Arduino (i.e. machine not designed to support it) you would have to deal the same old-school way as in '80. Look at some example Arduino library code. Code can countdown and query hardware register. Countdown and query. Like thirty years ago we used to prior DMA.. There were (and still are) competitions to make ultra small code. "Intros". They are machine code loaders. Unpacks the real code from initial 1kb, 4kb, 64kb. Unpacked code later generates procedural textures which imitates the real photos (instead of loading them).
  7. ..for me it is handling peripheral devices (app should not talk directly to peripheral devices because of security concerns).. allocation of memory.. creation threads and processes and running in virtual environment (after introduction of MMU in CPUs).. devices infrastructure.. external libraries infrastructure.. file systems (on higher-level of drive devices).. low-level gfx (higher-level of gfx driver; DirectX/Direct3D equivalent).. low-level sfx (higher-level of sfx driver; DirectX/DirectSound equivalent).. GUI.. networking (higher-level of networking devices) etc. etc. Higher levels of OS are built on the top of lower levels, like onion. Typical modern app programmer is often recreating the all these things in C++ classes, to have environment which is independent of platform. i.e. instead of making thread by WinAPI CreateThread() one will use wrapper, which will call OS-specific function instead. Then use C++ wrapper class.
  8. ..making OS is easy.. Nowadays you know what you have to do. Don't have to design and think about how to do it. Everybody who were writing code in '80 were doing so (they were force to do so!).. any '80 application/game, and some early '90, were intercepting entire functionality of the computer, having to deal with hardware registers (and the all external devices) and program them by themselves.. etc. etc. At that time, entire OS could fit in 4 KB, 8 KB, 16 KB of ROM. Don't tell me you cannot code 16384 bytes of machine code? Seriously? I could write OS in a few hours. In '80-'90 years I was writing 500+ lines of machine code in a few hours. The only limit is amount of beer and pizza around me.. Currently what is considered "OS" is extremely (EXTREMELY) overbloated.. Nowadays, "OS" has built-in TCP/IP stack.. (check when Windows get TCP/IP stack, and then MacOS get TCP/IP stack built-in) Nowadays, "OS" has built-in Internet browser.. (check when Windows get IE, and then MacOS get web browser built-in) Nowadays, "OS" has built-in FTP client.. Nowadays, "OS" has built-in simple text editor (NotePad) and more complex text editor (WordPad).. etc. etc. ..but it won't be "your OS".. you made almost nothing in it..
  9. Show photos of your "projects"... Attach in your reply to this forum.. Old-school programming device was without DMA, which means CPU takes care of everything, and executes function after xxx milliseconds, and writes sample of data... Which evolved to "execute interrupt after xxx milliseconds", and write stuff, and return from interrupt. Which evolved to blocks of data, after sending/receiving them aka "DMA". i.e. set start address of block, size of block, parameters, and go... then interrupt happens if it is sent/received.. and CPU regains control after a while (taking care of the other things in meanwhile).
  10. Machine code, Assembler, C. For higher levels of OS C++.
  11. Start from something simpler. Make Arduino compatible board.. "You must learn to crawl before you can walk"
  12. Curve which goes through the all control points is called e.g. Catmull-Rom spline. https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline https://en.wikipedia.org/wiki/Catmull-Rom_spline https://en.wikipedia.org/wiki/Cubic_Hermite_spline When you know what are positions of control points, you can interpolate and receive position between them, still preserving original curvature (with some level of precision).
  13. No. It's zero Coulomb net charge. If you would have unpaired electrons and/or protons, net charge would be different than zero.
  14. Definitely. Apart of religion, I would also add: regardless of sexuality (hetero/homo/trans), regardless of gender (woman/man), regardless of nationality, regardless of race etc. etc. But the problem with fundamentalists (on all sides) is that they want to impose their fundamentalist principles on everyone.
  15. ..when there is enough bad will (and/or stupidity) (which appears so, looking at this world, at the current moment, and considering what happens worldwide) everything is plausible.. The result will be mass extinction of humankind. There are ~7.7 billions of people just because of science. Mass production of food requires artificial fertilizers. We could imagine situation in which people 'forget' how to make artificial fertilizers and rapidly there is no food for billions of people. Thanks to modern science (i.e. vaccines) survival of childhood is a "piece of cake" now. In XIX and earlier majority of people were dying prior reaching adulthood. People had even 7-8 children, from which half of them were dying. No need to go back to XIX century to see that just in half of XX century 35% of children in Africa were dying. (modern western parents worry about car accident of their son/daughter, or overdosage of narcotics, than illness) When you will read some historical books about Roman emperors or kings in the Middle Ages, you will learn that even the most richest and the most powerful people at that times were losing offspring, and pregnant women (maternal mortality ratio), in unbelievable quantity from perspective of modern times.. They had the best medics around them, and still failure.. There are very dangerous movements related to the alleged Catholic Church in Poland, which want to return to the "good old days", and with their stupidity increase the mortality rate of women (maternal mortality rate) in Poland..
  16. The speed of sound depends on the medium and its properties, such as pressure and temperature. The air is ~ 340 m/s at stp. Check what is the speed of sound in water ... much faster than in air..
  17. BTW, hyperloop and similar are not limited by air resistance as they work in vacuum or very low pressure. https://en.m.wikipedia.org/wiki/Hyperloop
  18. Rapid acceleration or deceleration can kill even without hitting anything. Brain is not attached to the skull very tightly and will smash on skull wall, cause fatal injury, internal bleeding and brain swelling. The first symptom of too high acceleration is shortened field of view with black areas on sides. Later lost of consciousness. Airplane pilots and astronauts are training to learn how to fight with it to some level. Some people could have heartattack during flight to the ground..
  19. ..in the hypothesis about infinite number of parallel Universes (or infinitely forever repeating, in the all possible ways), everybody which you know are molested in infinite number of Universes.. and there is infinite number of Universes in which you do not even exist.. and there is infinite number of Universes in which you are woman, man, heterosexual or homosexual, or transsexual etc... and you do the all jobs of the world.. you are homeless or being billionaire, businessman, actor, politician, king and queen, etc. etc.. and there is infinite number of Universes in which you are killed in every possible way, in accident or murder, in every second/millisecond/picosecond of your hypothetical existence.. It also means there is infinite number of Universes, in which you're not abused.. and infinite number of Universes in which you are happy.. Decide in which Universe you want to be now. Retrocausality has nothing to do with hypothesis about parallel Universes, or forever repeating Big Bang, in the all possible ways. The future (or parallel) has no influence on existing. If it would have influence, it could be experimentally detected.
  20. Waves of what? For experiments with light, the simplest tools are: - diffraction grating ($14 on eBay) - prism ($10-15 on eBay) - single-slit and double-slit ($12 on Amazon) - polarization filters ($13 on Amazon) (make sure there are two!) - lasers (you should get red, green and blue at least) The all these toys will cost you ~$100, and you will be able to make experiments with light at home.. You need prism. Get it on eBay or Amazon. Cheap stuff.
  21. ..I even gave the equation in the part of the post you cut off ...
  22. Oscillation frequency of oscillator, or other macroscopic body, has nothing to do with photon frequency... Photons have energy E=h*f where f=c/wavelength so E=h*c/wavelength Frequency of photon is used as parameter to calculate energy of photon, and other properties of photon. Purple violet photons have wavelengths between 380 nm to 450 nm, which is approximately ~ 3.26 eV to 2.76 eV (which is ~ 5.23*10^-19 J to 4.414*10^-19 J) When photon is absorbed, its energy increase internal energy of medium which absorbed it. To get 1 Watt = 1 Joule per second, you need to 1 J / 5.23*10^-19 J = 1.9*10^18 photons absorbed with 100% efficiency, and even more at lower efficiency. Per second.
  23. What?! It is 1 divided by 2. Half. 0.5 .... Absolute nonsense. Absolutely not.. Correct way, I told you already, would be playing with digital camera. Drop something from well known height e.g. 2 meters, record it on camera, load video file in some free video editing tool e.g. VirtualDub. Then analyze where used to be (d (distance) parameter) dropped object in time, at which frame, during flying to the ground. Then make spreadsheet of gathered data in e.g. OpenOffice SpreadSheet or Excel. Then figure out equation from data. And you end up with a=2*d/t^2
  24. (It should be 9.8 m/s^2 or 9.8 m * s^-2) g (or a) is coefficient used in equation of distance traveled by body i.e. d = 1/2 * a * t^2 "second square" unit of a, cancels out with "second square" unit of t^2. Simple cancellation of units. m/s^-2 * s^2 = m To calculate acceleration of the body, you transform this equation from d = 1/2 * a * t^2 to a=2*d/t^2 or you can derive time: t=sqrt(2*d/a) https://en.wikipedia.org/wiki/Equations_for_a_falling_body How scientists get this equation? They were releasing objects from well known height, and measuring time of flight to the ground. You release something from 1 meter. Measure time. Release something from 2 meters. Measure time. Release something from 4 meters. Measure time. etc. (it is interesting experiment. In the modern times we can record it on camera, and see it in slow motion speed, and easily measure time using frames-per-second of video) You will receive sequence of pair of data. Distance of flight and time. From them you can extract "g" (or "a") coefficient. Then you can predict time of flight of something placed at any arbitrary height. How long you will be flying from 3 km? t=sqrt(2*3000/9.81)=24.731 seconds (assuming no air resistance, thus no terminal velocity)
  25. ...did not you just posted thread with title "what is the 3rd dimension?"..... ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.