summaryrefslogtreecommitdiff
path: root/frontends/calculator/CEdev/examples/fileio_factorize/src
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-04-13 12:40:52 -0400
committerAndrew Opalach <andrew@akon.city> 2019-04-13 12:40:52 -0400
commit55bfff7cf6541caac172b43186cf14405185b14d (patch)
treec1ae99d2b39f8df8933d81ec2e61e81050bdb410 /frontends/calculator/CEdev/examples/fileio_factorize/src
parent761462861fc1228e65546c4e0f877d5212320082 (diff)
downloadcetris-55bfff7cf6541caac172b43186cf14405185b14d.tar.gz
cetris-55bfff7cf6541caac172b43186cf14405185b14d.tar.bz2
cetris-55bfff7cf6541caac172b43186cf14405185b14d.zip
fix curses on linux
Diffstat (limited to 'frontends/calculator/CEdev/examples/fileio_factorize/src')
-rw-r--r--frontends/calculator/CEdev/examples/fileio_factorize/src/main.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/frontends/calculator/CEdev/examples/fileio_factorize/src/main.c b/frontends/calculator/CEdev/examples/fileio_factorize/src/main.c
index 3be9992..c95bb46 100644
--- a/frontends/calculator/CEdev/examples/fileio_factorize/src/main.c
+++ b/frontends/calculator/CEdev/examples/fileio_factorize/src/main.c
@@ -1,75 +1,75 @@
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <tice.h>
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <fileioc.h>
-
-void prime_factors(unsigned int n);
-
-int primes[512];
-unsigned int total_primes = 0;
-
-/* Main Function */
-void main(void) {
- /* Declare some variables */
- real_t *real_in;
- list_t *list_out;
- unsigned i;
- int in;
-
- /* Clear the homescreen */
- os_ClrHome();
-
- /* Get the answer variable */
- if (ti_RclVar(TI_REAL_TYPE, ti_Ans, &real_in)) return;
- if ((in = os_RealToInt24(real_in)) < 1) return;
-
- /* Get the prime factors of the input */
- prime_factors((unsigned)in);
-
- /* Create a list to store the primes */
- if (!total_primes) return;
- list_out = ti_MallocList(total_primes); // Same as ti_AllocList(total_primes, malloc)
-
- /* Write out the list of primes */
- for (i=0; i<total_primes; i++) {
- list_out->items[i] = os_Int24ToReal(primes[i]);
- }
-
- /* Set the new answer */
- ti_SetVar(TI_REAL_LIST_TYPE, ti_Ans, list_out);
-}
-
-/* Store to an array all the prime numbers */
-void prime_factors(unsigned int n) {
- unsigned int div, end;
-
- while (!(n % 2)) {
- primes[total_primes++] = 2;
- n /= 2;
- }
-
- if (n == 1) return;
-
- div = 3;
- end = sqrt(n);
-
- while (div <= end) {
- if (!(n % div)) {
- do {
- primes[total_primes++] = div;
- n /= div;
- } while (!(n % div));
- if (n == 1) return;
- end = sqrt(n);
- }
- div += 2;
- }
-
- primes[total_primes++] = n;
-}
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <tice.h>
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <fileioc.h>
+
+void prime_factors(unsigned int n);
+
+int primes[512];
+unsigned int total_primes = 0;
+
+/* Main Function */
+void main(void) {
+ /* Declare some variables */
+ real_t *real_in;
+ list_t *list_out;
+ unsigned i;
+ int in;
+
+ /* Clear the homescreen */
+ os_ClrHome();
+
+ /* Get the answer variable */
+ if (ti_RclVar(TI_REAL_TYPE, ti_Ans, &real_in)) return;
+ if ((in = os_RealToInt24(real_in)) < 1) return;
+
+ /* Get the prime factors of the input */
+ prime_factors((unsigned)in);
+
+ /* Create a list to store the primes */
+ if (!total_primes) return;
+ list_out = ti_MallocList(total_primes); // Same as ti_AllocList(total_primes, malloc)
+
+ /* Write out the list of primes */
+ for (i=0; i<total_primes; i++) {
+ list_out->items[i] = os_Int24ToReal(primes[i]);
+ }
+
+ /* Set the new answer */
+ ti_SetVar(TI_REAL_LIST_TYPE, ti_Ans, list_out);
+}
+
+/* Store to an array all the prime numbers */
+void prime_factors(unsigned int n) {
+ unsigned int div, end;
+
+ while (!(n % 2)) {
+ primes[total_primes++] = 2;
+ n /= 2;
+ }
+
+ if (n == 1) return;
+
+ div = 3;
+ end = sqrt(n);
+
+ while (div <= end) {
+ if (!(n % div)) {
+ do {
+ primes[total_primes++] = div;
+ n /= div;
+ } while (!(n % div));
+ if (n == 1) return;
+ end = sqrt(n);
+ }
+ div += 2;
+ }
+
+ primes[total_primes++] = n;
+}