vend13.py

Created by schraf

Created on May 15, 2022

364 Bytes

Suite à une publication de Numworks concernant les vendredis 13, voici un petit programme qui permet de compter combien de fois, sur une période de 400 ans, il y a eu de lundi 13, mardi 13 etc. On constate qu’il y a effectivement eu plus de vendredis 13 !

J’ai utilisé la formule de Schwerdtfeger pour le calcul.

Quelques unes de mes vidéos Youtube sur des sujets similaires :

Théorie des calendriers perpétuels portatifs

Astuce pour retrouver le jour de la semaine d’une date quelconque


jsem = [ 'Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam' ]
stats = [ 0, 0, 0, 0, 0, 0, 0 ]
t = [ 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 ]

for a in range(2000, 2400):
  for m in range(1, 13):
    y = a - (m < 3) 
    y += y // 4 - y // 100 + y // 400 + t[m - 1] + 13
    stats[ y % 7 ] += 1

for (l, v) in zip(jsem, stats):
 print('{} : {}'.format(l,v))

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.