C (gcc), (削除) 116 (削除ここまで) (削除) 113 (削除ここまで) 110 bytes
Saved 3 bytes thanks to the man himself Arnauld!!!
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,17088/ *s%75%14|1);}d=r;}
Inputs a string and returns its Gödel number.
Uses the Magic 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
17088/ *s%75%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