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 Revisions

4 of 6
added 1108 characters in body
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

C (gcc), (削除) 116 (削除ここまで) 113 bytes

d;g;p;r;f(char*s){for(p=r=1;*s;++s){for(g=0;!g;)for(g=d=p++;d>1;)g=g&&p%d--;r*=pow(p,18160/ *s%80%30%14|1);}d=r;}

Try it online!

Inputs a string and returns its Gödel number.

Uses the ASCII to Gödel value mapping formula from Arnauld's JavaScript answer.

Commented Code

d;g;p;r;f(char*s){ // declare variables and function 
 r=1 // init return value r to 1 
 p= // init prime number p to 1 
 for( ;*s;++s){ // loop over chars in s 
 for(g=0;!g;) // loop until we find the next prime 
 p++ // start by bumping p 
 d= // init divisor d to p-1 
 g= // set g to non-zero p-1 as well 
 for( ;d>1;) // loop over d until its 2
 g=g&&p%d--; // g with only remain non-zero if 
 // p is the next prime number 
 r*=pow(p, );// multiply r by p to the power of
 18160/ *s%80%30%14|1 // the Gödel value for the ASCII 
 // code, need the space so it's not 
 } // interpreted as start of comment 
 d=r; // return r
} //
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

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