Commit cfec60cd authored by kjc015's avatar kjc015
Browse files

prelab complete

parent 14f2a283
#exit.s
.text
.global _start
_start:
li a0, 42
li a7, 93
ecall
/*
real:19.823s
user:19.508s
sys:0.308s
*/
#include <stdio.h>
#include <stdlib.h>
int is_prime(int n)
{
int i;
for (i = 2; i < (n-1); i++){
if ((n%i) == 0){
return 0;
}
}
return 1;
}
int main (int argc, char* argv[])
{
int i, n = 0, maxnum=80;
if (argc > 1){
maxnum = atoi(argv[1]);
}
for (i = 2; n < maxnum; i++){
if (is_prime(i)){
printf("%7d", i);
n++;
if ((n % 10) == 0){
printf("\n");
}
}
}
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment