Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SNNN数のライブラリを作成してみた。

Posted at

SNNN数のライブラリーを作成してみた。

snnnum.py
import math

def reverse(num):
    if num==0:
        return -1
    return int(math.log10((num*9+7)/34))

def common(n):
    return int((34*10**n-7)/9)

def isPrime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            return False
    return True

def baseFromIsPrime(x):
    return isPrime(common(x))

ちゃんと動くか検証

app.json.py
import snnnum
n=int(input("数を入力"))
n1=snnnum.common(n)
n2=snnnum.reverse(n1)
n3=snnnum.isPrime(n1)
print("common:",n1)
print("reverse:",n2)
print("is prime:",n3)
print("reisprm:",snnnum.baseFromIsPrime(n2))

動いた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

@yuri_love's pickup articles

yuri_love

@yuri_love(温泉好きの姫男子 ロゼガルド)

C/C++/C#でゲーム開発,PythonでマルチプラットフォームGUI開発,ラムダ式,ゲームプログラム、その他開発など自分で調べて実証済みのものを発信していきたいと思う。https://twitter.com/reiwawakamono <-是非良ければ、こちらのフォローもよろしくでーす(私もフォローしてまーす)。沢山知識を分かち合って切磋琢磨しようと思ってます。

Comments

No comments

Let's comment your feelings that are more than good

Qiita Conference 2025 Autumn will be held!: 11/5(Wed) - 11/7(Fri)

Qiita Conference is Qiita's largest tech conference, dedicated to engineers in the age of AI!

Keynote Speaker

piacere, Tsuyoshi Ushio, Esteban Suarez, Takuto Wada, seya, MinoDriven, Toshihiro Ichitani, Karaage, Yoshimasa Iwase, Matz, Minorun and more…

View event details

Being held Article posting campaign

0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Login to continue?

Login or Sign up with social account

Login or Sign up with your email address