Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Processing, 161 bytes

Processing, 161 bytes

int p(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void t(int n){for(int i=1,j;i<=n;i++){if(p(i)<1)continue;for(j=i;j>0;j--)print(p(j)<1?"":j);}}

One function does the primality checking, the other does the printing. Call it by t(7)

###Ungolfed

Ungolfed

The first function does the primality checking. It returns an int instead of a boolean since this way more bytes are saved. (int instead of boolean, 0 instead of false, 1 instead of true)

int Q103891p(int n){
 for(int k=1;++k<=sqrt(n);)
 if(n%k<1)return 0;
 return 1;
}

The second function prints out the string. It iterates through every number, if it is not a prime, skip to the next iteration. If it is a prime, it continues down to the printing inside another for-loop. Again, if the number is prime, then we print it, otherwise not.

void Q103891(int n){
 for(int i=1,j;i<=n;i++){
 if(p(i)<1)continue;
 for(j=i;j>0;j--)
 print(p(j)<1?"":j);
 }
}

#Processing, 161 bytes

int p(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void t(int n){for(int i=1,j;i<=n;i++){if(p(i)<1)continue;for(j=i;j>0;j--)print(p(j)<1?"":j);}}

One function does the primality checking, the other does the printing. Call it by t(7)

###Ungolfed

The first function does the primality checking. It returns an int instead of a boolean since this way more bytes are saved. (int instead of boolean, 0 instead of false, 1 instead of true)

int Q103891p(int n){
 for(int k=1;++k<=sqrt(n);)
 if(n%k<1)return 0;
 return 1;
}

The second function prints out the string. It iterates through every number, if it is not a prime, skip to the next iteration. If it is a prime, it continues down to the printing inside another for-loop. Again, if the number is prime, then we print it, otherwise not.

void Q103891(int n){
 for(int i=1,j;i<=n;i++){
 if(p(i)<1)continue;
 for(j=i;j>0;j--)
 print(p(j)<1?"":j);
 }
}

Processing, 161 bytes

int p(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void t(int n){for(int i=1,j;i<=n;i++){if(p(i)<1)continue;for(j=i;j>0;j--)print(p(j)<1?"":j);}}

One function does the primality checking, the other does the printing. Call it by t(7)

Ungolfed

The first function does the primality checking. It returns an int instead of a boolean since this way more bytes are saved. (int instead of boolean, 0 instead of false, 1 instead of true)

int Q103891p(int n){
 for(int k=1;++k<=sqrt(n);)
 if(n%k<1)return 0;
 return 1;
}

The second function prints out the string. It iterates through every number, if it is not a prime, skip to the next iteration. If it is a prime, it continues down to the printing inside another for-loop. Again, if the number is prime, then we print it, otherwise not.

void Q103891(int n){
 for(int i=1,j;i<=n;i++){
 if(p(i)<1)continue;
 for(j=i;j>0;j--)
 print(p(j)<1?"":j);
 }
}
added 767 characters in body
Source Link
user41805
  • 13.4k
  • 6
  • 43
  • 88

#Processing, 161 bytes

int p(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void t(int n){for(int i=1,j;i<=n;i++){if(p(i)<1)continue;for(j=i;j>0;j--)print(p(j)<1?"":j);}}

One function does the primality checking, the other does the printing. Call it by t(7)

###Ungolfed

The first function does the primality checking. It returns an int instead of a boolean since this way more bytes are saved. (int instead of boolean, 0 instead of false, 1 instead of true)

int Q103891p(int n){
 for(int k=1;++k<=sqrt(n);)
 if(n%k<1)return 0;
 return 1;
}

The second function prints out the string. It iterates through every number, if it is not a prime, skip to the next iteration. If it is a prime, it continues down to the printing inside another for-loop. Again, if the number is prime, then we print it, otherwise not.

void Q103891(int n){
 for(int i=1,j;i<=n;i++){
 if(p(i)<1)continue;
 for(j=i;j>0;j--)
 print(p(j)<1?"":j);
 }
}

#Processing, 161 bytes

int p(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void t(int n){for(int i=1,j;i<=n;i++){if(p(i)<1)continue;for(j=i;j>0;j--)print(p(j)<1?"":j);}}

One function does the primality checking, the other does the printing. Call it by t(7)

#Processing, 161 bytes

int p(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void t(int n){for(int i=1,j;i<=n;i++){if(p(i)<1)continue;for(j=i;j>0;j--)print(p(j)<1?"":j);}}

One function does the primality checking, the other does the printing. Call it by t(7)

###Ungolfed

The first function does the primality checking. It returns an int instead of a boolean since this way more bytes are saved. (int instead of boolean, 0 instead of false, 1 instead of true)

int Q103891p(int n){
 for(int k=1;++k<=sqrt(n);)
 if(n%k<1)return 0;
 return 1;
}

The second function prints out the string. It iterates through every number, if it is not a prime, skip to the next iteration. If it is a prime, it continues down to the printing inside another for-loop. Again, if the number is prime, then we print it, otherwise not.

void Q103891(int n){
 for(int i=1,j;i<=n;i++){
 if(p(i)<1)continue;
 for(j=i;j>0;j--)
 print(p(j)<1?"":j);
 }
}
Post Undeleted by user41805
added 11 characters in body
Source Link
user41805
  • 13.4k
  • 6
  • 43
  • 88

#Processing, 138161 bytes

int ip(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void at(int n){for(int i=0i=1,j;i++<=n;j;i<=n;i++)for{if(j=i;jp(i)<1)continue;for(j=i;j>0;j-->1;)print(ip(j)>0<1?j:"":j);}}

One function does the primality checking, the other does the printing. Call it by at(7)

DOESN'T WORK

#Processing, 138 bytes

int i(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void a(int n){for(int i=0,j;i++<=n;)for(j=i;j-->1;)print(i(j)>0?j:"");}

One function does the primality checking, the other does the printing. Call it by a(7)

DOESN'T WORK

#Processing, 161 bytes

int p(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void t(int n){for(int i=1,j;i<=n;i++){if(p(i)<1)continue;for(j=i;j>0;j--)print(p(j)<1?"":j);}}

One function does the primality checking, the other does the printing. Call it by t(7)

deleted 35 characters in body
Source Link
user41805
  • 13.4k
  • 6
  • 43
  • 88
Loading
Post Deleted by user41805
Source Link
user41805
  • 13.4k
  • 6
  • 43
  • 88
Loading

AltStyle によって変換されたページ (->オリジナル) /