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?

年月日(8桁)の素因数分解

Last updated at Posted at 2025-01-31

はじめに

  • ここでは年月日を繋げて8桁の数値にしたとき、その数値を素因数分解した結果を載せる
  • 間違いあればご指摘ください
  • 以下の記事の派生(上位互換)

概要

  • 特に意味はありませんが、「今日はxxxですねと」いう会話をするときに利用できるかもしれない
  • 弊社では朝礼のスピーチが順番に回ってくるのでその時に使えるかもしれない

前提

  • 2001年から2100年の期間を対象とする
    • 分量多く投稿できないので記事には2025年と特別なもののみ記載
  • 月日は0埋めし常に2桁ずつの数値とする
    • 例:20250101

詳細

  • 事前に最大値までの素数を求めておく
  • 8桁の数値を生成し、素因数分解する
  • 素因数分解した結果全ての積を求め元の値に一致するかどうかを確認

プログラム

  • javaで実装
  • 実際のコード(import等は割愛)は後述
    • かなり見苦しい部分があります

public class factorization1 {

	private static int TRIAL_COUNT=30;
	private static  boolean DEBUG = true;
	private static int MIN=20;
	private static int MAX=21010000;
	private static String START_DATE="2001-01-01";
	private ArrayList<Integer> factors = new ArrayList<Integer>();
	
	public static void main(String[] args) {
		debuglog("start");
		factorization1 f = new factorization1();
		f.createFactors();
		//f.range();
		try {
			f.date();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		debuglog("end");
	}
	private void range() {
		ArrayList<Integer> resultfactors;
		for(int i=MIN; i<MAX; i++) {
			resultfactors = getFactors(i);
			System.out.print(String.format("%d\t",i));
			outputFactors(resultfactors,true,i);
		}
		
	}
	private void date() throws ParseException {
		   SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		   Date date = dateFormat.parse(START_DATE);
		   Calendar calendar = Calendar.getInstance();
	       calendar.setTime(date);

	       SimpleDateFormat getYearFormat = new SimpleDateFormat("yyyy");
	       SimpleDateFormat getMonthFormat = new SimpleDateFormat("MM");
	       SimpleDateFormat getDayFormat = new SimpleDateFormat("dd");

			ArrayList<Integer> resultfactors;
	       while(!getYearFormat.format(date).equals("2101")) {
	    	   String strNumber = String.format("%s%s%s",getYearFormat.format(date),getMonthFormat.format(date),getDayFormat.format(date) );
	    	   int number = Integer.parseInt(strNumber);
    		   String output = String.format("|%s|%s|%s|",
    				   getYearFormat.format(date),
    				   getMonthFormat.format(date),
    				   getDayFormat.format(date));
    		   System.out.print(output);
	    	   calendar.add(Calendar.DAY_OF_YEAR, 1);
	    	   date = calendar.getTime();
	    	   resultfactors = getFactors(number);
	    	   System.out.print(String.format("%d|",number));
	    	   outputFactors(resultfactors,false,number);
	       }
	}
	public static void debuglog(String str) {
		if(DEBUG) {
			System.out.println(str);
		}
	}
	public static void outputFactors(ArrayList<Integer> ints,boolean isCheck, int checkValue) {
		int check=1;
		boolean first = true;
		for(int i : ints) {
			if(first) {
				first=false;
			} else {
				System.out.print("*");
			}
			if(isCheck) {
				check*=i;
			}
			System.out.print(String.format("%d",i));
		}
		if(isCheck) {
			System.out.println(String.format("|check : %d|",check));
			if(check!=checkValue) {
				System.out.println("Error!");
			}
		} else {
			System.out.println(String.format("|%d|",ints.size()));
		}
	}
	
	private void createFactors() {

		for(int i=2; i<=MAX; i++) {
			// 素数のみ格納する。
			if(isPrime(i,TRIAL_COUNT)) {
				factors.add(i);
			}
		}
		//outputFactors(factors,false,0);
	}
	private ArrayList<Integer> getFactors(int k) {
		ArrayList<Integer> k_factors = new ArrayList<Integer>();
		for(Integer value : factors) {
			int temp = value;
			while(k%temp==0) {
				k /= temp;
				k_factors.add(temp);
			}
		}
		return k_factors;
	}
	public static boolean isPrime(int n,int k){
		// 2は素数
		if(n==2) {
			return true;
		}
		
		// 1は素数ではない
		// 2以外の偶数は素数ではない
		if(n==1 || n%2==0) {
			return false;
		}
		// n-1を2のべき乗で輪って2^s*dの形式に変形
		int d=n-1;
		int s=0; 
		while (d%2 ==0) {
			d = d/2;
			s++;
		}
		// 判定サイクル(k回)
		for(int i=0; i<k; i++) {
			boolean isPP = false;
			// 1からn-1の範囲より整数aをランダムに選ぶ
			int a=(int)(Math.round((n-2)*Math.random())+1);
			// a^d mod n が1もしくはn-1ならnはprobably prime
			int r=modPow(a,d,n);
			if(r==1||r==n-1) {
				isPP = true;
			}
			// r^2 mod n が-1なら、nはprobably prime
			for(int j=0; j<s; j++) {
				r=modPow(r,2,n);
				if(r==n-1) {
					isPP=true;
				}
			}
			// 上記のどちらにも当てはまらない場合、nはcomposite
			if(!isPP) {
				return false;
			}
		}
		return true;
	}
	private static int modPow(long x,int k, int m) {
		if(k==0) {
			return 1;
		}
		if(k%2 ==0) {
			return modPow(x*x%m, k/2,m);
		} else {
			return (int) (modPow(x,k-1,m)*x%m);
		}
	}

}

一覧

  • 日付の一覧は素因数分解の結果を記載
    • 素数の場合はその数値そのものを記載
  • 素因数の個数も掲載
  • 同一の素数2つで素因数分解される年月日は今回の範囲には存在しなかった
  • また2001年から2100年までで、最大の素因数の個数は18
    • その年月日は2つある(以下)
数値 素因数分解の結果 素因数の個数
2025 06 24 20250624 2×2×2×2×2×2×2×2×2×2×2×2×2×2×2×2×3×103 18
2057 01 12 20570112 2×2×2×2×2×2×2×2×2×2×2×2×2×3×3×3×3×31 18
  • 2025年の年月日のみ記載
数値 素因数分解の結果 素因数の個数
2025 01 01 20250101 20250101 1
2025 01 02 20250102 2×3×3375017 3
2025 01 03 20250103 1171×17293 2
2025 01 04 20250104 2×2×2×7×431×839 6
2025 01 05 20250105 3×5×19×41×1733 5
2025 01 06 20250106 2×10125053 2
2025 01 07 20250107 137×147811 2
2025 01 08 20250108 2×2×3×3×3×97×1933 7
2025 01 09 20250109 11×61×103×293 4
2025 01 10 20250110 2×5×1039×1949 4
2025 01 11 20250111 3×7×17×131×433 5
2025 01 12 20250112 2×2×2×2×2×2×2×2×2×39551 10
2025 01 13 20250113 13×359×4339 3
2025 01 14 20250114 2×3×3375019 3
2025 01 15 20250115 5×4050023 2
2025 01 16 20250116 2×2×5062529 3
2025 01 17 20250117 3×3×2250013 3
2025 01 18 20250118 2×7×1446437 3
2025 01 19 20250119 43×470933 2
2025 01 20 20250120 2×2×2×3×5×11×23×23×29 9
2025 01 21 20250121 20250121 1
2025 01 22 20250122 2×10125061 2
2025 01 23 20250123 3×71×95071 3
2025 01 24 20250124 2×2×19×266449 4
2025 01 25 20250125 5×5×5×7×23143 5
2025 01 26 20250126 2×3×3×13×86539 5
2025 01 27 20250127 73×457×607 3
2025 01 28 20250128 2×2×2×2×17×74449 6
2025 01 29 20250129 3×109×61927 3
2025 01 30 20250130 2×5×31×65323 4
2025 01 31 20250131 11×1840921 2
2025 02 01 20250201 3×6750067 2
2025 02 02 20250202 2×7×191×7573 4
2025 02 03 20250203 20250203 1
2025 02 04 20250204 2×2×3×13×271×479 6
2025 02 05 20250205 5×43×97×971 4
2025 02 06 20250206 2×10125103 2
2025 02 07 20250207 3×3×29×77587 4
2025 02 08 20250208 2×2×2×2×2×11×57529 7
2025 02 09 20250209 7×2892887 2
2025 02 10 20250210 2×3×5×761×887 5
2025 02 11 20250211 37×263×2081 3
2025 02 12 20250212 2×2×23×103×2137 5
2025 02 13 20250213 3×17×397063 3
2025 02 14 20250214 2×67×151121 3
2025 02 15 20250215 5×139×29137 3
2025 02 16 20250216 2×2×2×3×3×3×7×59×227 9
2025 02 17 20250217 13×1557709 2
2025 02 18 20250218 2×10125109 2
2025 02 19 20250219 3×11×19×32297 4
2025 02 20 20250220 2×2×5×853×1187 5
2025 02 21 20250221 197×102793 2
2025 02 22 20250222 2×3×3375037 3
2025 02 23 20250223 7×31×93319 3
2025 02 24 20250224 2×2×2×2×1265639 5
2025 02 25 20250225 3×3×5×5×90001 5
2025 02 26 20250226 2×347×29179 3
2025 02 27 20250227 20250227 1
2025 02 28 20250228 2×2×3×41×79×521 6
2025 03 01 20250301 1697×11933 2
2025 03 02 20250302 2×97×104383 3
2025 03 03 20250303 3×211×31991 3
2025 03 04 20250304 2×2×2×2×2×2×23×13757 8
2025 03 05 20250305 5×163×24847 3
2025 03 06 20250306 2×3×3×1125017 4
2025 03 07 20250307 7×11×79×3329 4
2025 03 08 20250308 2×2×13×151×2579 5
2025 03 09 20250309 3×6750103 2
2025 03 10 20250310 2×5×41×49391 4
2025 03 11 20250311 3461×5851 2
2025 03 12 20250312 2×2×2×3×843763 5
2025 03 13 20250313 491×41243 2
2025 03 14 20250314 2×7×19×76129 4
2025 03 15 20250315 3×3×5×17×103×257 6
2025 03 16 20250316 2×2×31×163309 4
2025 03 17 20250317 20250317 1
2025 03 18 20250318 2×3×11×11×27893 5
2025 03 19 20250319 1361×14879 2
2025 03 20 20250320 2×2×2×2×5×269×941 7
2025 03 21 20250321 3×7×13×74177 4
2025 03 22 20250322 2×37×273653 3
2025 03 23 20250323 29×698287 2
2025 03 24 20250324 2×2×3×3×3×3×62501 7
2025 03 25 20250325 5×5×810013 3
2025 03 26 20250326 2×47×367×587 4
2025 03 27 20250327 3×23×293483 3
2025 03 28 20250328 2×2×2×7×7×51659 6
2025 03 29 20250329 11×1840939 2
2025 03 30 20250330 2×3×5×337×2003 5
2025 03 31 20250331 157×128983 2
2025 04 01 20250401 20250401 1
2025 04 02 20250402 2×3×293×11519 4
2025 04 03 20250403 2633×7691 2
2025 04 04 20250404 2×2×127×39863 4
2025 04 05 20250405 3×3×3×3×3×5×7×2381 8
2025 04 06 20250406 2×11×920473 3
2025 04 07 20250407 71×223×1279 3
2025 04 08 20250408 2×2×2×3×409×2063 6
2025 04 09 20250409 19×31×34381 3
2025 04 10 20250410 2×5×29×69829 4
2025 04 11 20250411 3×659×10243 3
2025 04 12 20250412 2×2×7×13×55633 5
2025 04 13 20250413 20250413 1
2025 04 14 20250414 2×3×3×61×18443 5
2025 04 15 20250415 5×67×60449 3
2025 04 16 20250416 2×2×2×2×443×2857 6
2025 04 17 20250417 3×11×17×36097 4
2025 04 18 20250418 2×103×197×499 4
2025 04 19 20250419 7×23×73×1723 4
2025 04 20 20250420 2×2×3×5×43×47×167 7
2025 04 21 20250421 20250421 1
2025 04 22 20250422 2×1511×6701 3
2025 04 23 20250423 3×3×83×27109 4
2025 04 24 20250424 2×2×2×677×3739 5
2025 04 25 20250425 5×5×13×13×4793 5
2025 04 26 20250426 2×3×7×7×68879 5
2025 04 27 20250427 3221×6287 2
2025 04 28 20250428 2×2×11×19×24223 5
2025 04 29 20250429 3×251×26893 3
2025 04 30 20250430 2×5×2025043 3
2025 05 01 20250501 3×6750167 2
2025 05 02 20250502 2×17×31×19213 4
2025 05 03 20250503 7×13×222533 3
2025 05 04 20250504 2×2×2×3×3×19×113×131 8
2025 05 05 20250505 5×11×53×6947 4
2025 05 06 20250506 2×43×83×2837 4
2025 05 07 20250507 3×37×241×757 4
2025 05 08 20250508 2×2×1847×2741 4
2025 05 09 20250509 20250509 1
2025 05 10 20250510 2×3×5×7×96431 5
2025 05 11 20250511 23×59×14923 3
2025 05 12 20250512 2×2×2×2×1265657 5
2025 05 13 20250513 3×3×3×750019 4
2025 05 14 20250514 2×47×211×1021 4
2025 05 15 20250515 5×41×173×571 4
2025 05 16 20250516 2×2×3×11×13×11801 6
2025 05 17 20250517 7×2892931 2
2025 05 18 20250518 2×137×73907 3
2025 05 19 20250519 3×17×17×23357 4
2025 05 20 20250520 2×2×2×5×506263 5
2025 05 21 20250521 103×421×467 3
2025 05 22 20250522 2×3×3×1125029 4
2025 05 23 20250523 19×1065817 2
2025 05 24 20250524 2×2×7×7×103319 5
2025 05 25 20250525 3×5×5×193×1399 5
2025 05 26 20250526 2×29×89×3923 4
2025 05 27 20250527 11×1840957 2
2025 05 28 20250528 2×2×2×2×2×3×210943 7
2025 05 29 20250529 13×1557733 2
2025 05 30 20250530 2×5×2025053 3
2025 05 31 20250531 3×3×7×127×2531 5
2025 06 01 20250601 7×101×28643 3
2025 06 02 20250602 2×1811×5591 3
2025 06 03 20250603 3×3×23×97829 4
2025 06 04 20250604 2×2×11×17×27073 5
2025 06 05 20250605 5×4050121 2
2025 06 06 20250606 2×3×107×31543 4
2025 06 07 20250607 13×1181×1319 3
2025 06 08 20250608 2×2×2×2×7×47×3847 7
2025 06 09 20250609 3×6750203 2
2025 06 10 20250610 2×5×151×13411 4
2025 06 11 20250611 53×382087 2
2025 06 12 20250612 2×2×3×3×562517 5
2025 06 13 20250613 29×698297 2
2025 06 14 20250614 2×10125307 2
2025 06 15 20250615 3×5×7×11×89×197 6
2025 06 16 20250616 2×2×2×67×37781 5
2025 06 17 20250617 113×179209 2
2025 06 18 20250618 2×3×19×37×4801 5
2025 06 19 20250619 911×22229 2
2025 06 20 20250620 2×2×5×13×71×1097 6
2025 06 21 20250621 3×3×3×17×44119 5
2025 06 22 20250622 2×7×7×206639 4
2025 06 23 20250623 79×256337 2
2025 06 24 20250624 2×2×2×2×2×2×2×2×2×2×2×2×2×2×2×2×3×103 18
2025 06 25 20250625 5×5×5×5×32401 5
2025 06 26 20250626 2×11×23×31×1291 5
2025 06 27 20250627 3×6750209 2
2025 06 28 20250628 2×2×179×28283 4
2025 06 29 20250629 7×59×49033 3
2025 06 30 20250630 2×3×3×5×223×1009 6
2025 07 01 20250701 20250701 1
2025 07 02 20250702 2×3×3×3×47×79×101 7
2025 07 03 20250703 11×1840973 2
2025 07 04 20250704 2×2×2×2×89×14221 6
2025 07 05 20250705 3×5×1350047 3
2025 07 06 20250706 2×7×17×85087 4
2025 07 07 20250707 20250707 1
2025 07 08 20250708 2×2×3×1687559 4
2025 07 09 20250709 239×84731 2
2025 07 10 20250710 2×5×569×3559 4
2025 07 11 20250711 3×3×13×73×2371 5
2025 07 12 20250712 2×2×2×541×4679 5
2025 07 13 20250713 7×19×107×1423 4
2025 07 14 20250714 2×3×11×306829 4
2025 07 15 20250715 5×751×5393 3
2025 07 16 20250716 2×2×1667×3037 4
2025 07 17 20250717 3×53×127363 3
2025 07 18 20250718 2×23×193×2281 4
2025 07 19 20250719 31×61×10709 3
2025 07 20 20250720 2×2×2×2×2×3×3×5×7×7×7×41 12
2025 07 21 20250721 43×470947 2
2025 07 22 20250722 2×883×11467 3
2025 07 23 20250723 3×17×397073 3
2025 07 24 20250724 2×2×13×389437 4
2025 07 25 20250725 5×5×11×211×349 5
2025 07 26 20250726 2×3×3375121 3
2025 07 27 20250727 7×103×28087 3
2025 07 28 20250728 2×2×2×379×6679 5
2025 07 29 20250729 3×3×3×3×29×37×233 7
2025 07 30 20250730 2×5×113×17921 4
2025 07 31 20250731 2161×9371 2
2025 08 01 20250801 3×3×2250089 3
2025 08 02 20250802 2×11×11×13×41×157 6
2025 08 03 20250803 37×101×5419 3
2025 08 04 20250804 2×2×3×7×491×491 6
2025 08 05 20250805 5×4050161 2
2025 08 06 20250806 2×59×171617 3
2025 08 07 20250807 3×43×179×877 4
2025 08 08 20250808 2×2×2×17×17×19×461 7
2025 08 09 20250809 20250809 1
2025 08 10 20250810 2×3×3×3×3×5×23×1087 8
2025 08 11 20250811 7×2892973 2
2025 08 12 20250812 2×2×31×197×829 5
2025 08 13 20250813 3×11×613661 3
2025 08 14 20250814 2×10125407 2
2025 08 15 20250815 5×13×311551 3
2025 08 16 20250816 2×2×2×2×2×2×3×29×3637 9
2025 08 17 20250817 67×409×739 3
2025 08 18 20250818 2×7×7×206641 4
2025 08 19 20250819 3×3×2250091 3
2025 08 20 20250820 2×2×5×107×9463 5
2025 08 21 20250821 20250821 1
2025 08 22 20250822 2×3×3375137 3
2025 08 23 20250823 53×181×2111 3
2025 08 24 20250824 2×2×2×11×230123 5
2025 08 25 20250825 3×5×5×7×17×2269 6
2025 08 26 20250826 2×10125413 2
2025 08 27 20250827 19×281×3793 3
2025 08 28 20250828 2×2×3×3×13×43271 6
2025 08 29 20250829 257×78797 2
2025 08 30 20250830 2×5×103×19661 4
2025 08 31 20250831 3×359×18803 3
2025 09 01 20250901 11×401×4591 3
2025 09 02 20250902 2×7×23×61×1031 5
2025 09 03 20250903 3×19×29×12251 4
2025 09 04 20250904 2×2×2×71×101×353 6
2025 09 05 20250905 5×31×130651 3
2025 09 06 20250906 2×3×13×259627 4
2025 09 07 20250907 20250907 1
2025 09 08 20250908 2×2×5062727 3
2025 09 09 20250909 3×3×7×321443 4
2025 09 10 20250910 2×5×17×139×857 5
2025 09 11 20250911 193×317×331 3
2025 09 12 20250912 2×2×2×2×2×3×11×127×151 9
2025 09 13 20250913 587×34499 2
2025 09 14 20250914 2×37×283×967 4
2025 09 15 20250915 3×5×1350061 3
2025 09 16 20250916 2×2×7×7×277×373 6
2025 09 17 20250917 499×40583 2
2025 09 18 20250918 2×3×3×3×375017 5
2025 09 19 20250919 13×1557763 2
2025 09 20 20250920 2×2×2×5×347×1459 6
2025 09 21 20250921 3×83×167×487 4
2025 09 22 20250922 2×19×532919 3
2025 09 23 20250923 7×11×11×23909 4
2025 09 24 20250924 2×2×3×59×28603 5
2025 09 25 20250925 5×5×23×41×859 5
2025 09 26 20250926 2×2083×4861 3
2025 09 27 20250927 3×3×17×107×1237 5
2025 09 28 20250928 2×2×2×2×229×5527 6
2025 09 29 20250929 53×137×2789 3
2025 09 30 20250930 2×3×5×7×73×1321 6
2025 10 01 20251001 109×185789 2
2025 10 02 20251002 2×3×3375167 3
2025 10 03 20251003 73×277411 2
2025 10 04 20251004 2×2×83×181×337 5
2025 10 05 20251005 3×5×101×13367 4
2025 10 06 20251006 2×10125503 2
2025 10 07 20251007 7×41×41×1721 4
2025 10 08 20251008 2×2×2×2×2×2×2×3×3×17579 10
2025 10 09 20251009 197×102797 2
2025 10 10 20251010 2×5×13×155777 4
2025 10 11 20251011 3×11×613667 3
2025 10 12 20251012 2×2×17×297809 4
2025 10 13 20251013 20251013 1
2025 10 14 20251014 2×3×7×7×68881 5
2025 10 15 20251015 5×1259×3217 3
2025 10 16 20251016 2×2×2×2531377 4
2025 10 17 20251017 3×3×19×19×23×271 6
2025 10 18 20251018 2×67×79×1913 4
2025 10 19 20251019 29×698311 2
2025 10 20 20251020 2×2×3×5×337517 5
2025 10 21 20251021 7×2893003 2
2025 10 22 20251022 2×11×43×21407 4
2025 10 23 20251023 3×13×519257 3
2025 10 24 20251024 2×2×2×2×61×20749 6
2025 10 25 20251025 5×5×37×21893 4
2025 10 26 20251026 2×3×3×3×375019 5
2025 10 27 20251027 20251027 1
2025 10 28 20251028 2×2×7×131×5521 5
2025 10 29 20251029 3×17×31×12809 4
2025 10 30 20251030 2×5×2025103 3
2025 10 31 20251031 47×430873 2
2025 11 01 20251101 3×13×13×59×677 5
2025 11 02 20251102 2×10125551 2
2025 11 03 20251103 20251103 1
2025 11 04 20251104 2×2×2×2×2×3×193×1093 8
2025 11 05 20251105 5×7×578603 3
2025 11 06 20251106 2×29×101×3457 4
2025 11 07 20251107 3×3×3×379×1979 5
2025 11 08 20251108 2×2×43×281×419 5
2025 11 09 20251109 23×880483 2
2025 11 10 20251110 2×3×5×11×109×563 6
2025 11 11 20251111 2267×8933 2
2025 11 12 20251112 2×2×2×7×7×19×2719 7
2025 11 13 20251113 3×641×10531 3
2025 11 14 20251114 2×13×17×45817 4
2025 11 15 20251115 5×4050223 2
2025 11 16 20251116 2×2×3×3×157×3583 6
2025 11 17 20251117 71×285227 2
2025 11 18 20251118 2×2153×4703 3
2025 11 19 20251119 3×7×964339 3
2025 11 20 20251120 2×2×2×2×5×163×1553 7
2025 11 21 20251121 11×1841011 2
2025 11 22 20251122 2×3×31×108877 4
2025 11 23 20251123 20251123 1
2025 11 24 20251124 2×2×227×22303 4
2025 11 25 20251125 3×3×5×5×5×47×383 7
2025 11 26 20251126 2×7×1446509 3
2025 11 27 20251127 13×269×5791 3
2025 11 28 20251128 2×2×2×3×843797 5
2025 11 29 20251129 20251129 1
2025 11 30 20251130 2×5×41×49393 4
2025 12 01 20251201 23×880487 2
2025 12 02 20251202 2×10125601 2
2025 12 03 20251203 3×7×137×7039 4
2025 12 04 20251204 2×2×619×8179 4
2025 12 05 20251205 5×13×311557 3
2025 12 06 20251206 2×3×3×197×5711 5
2025 12 07 20251207 19×61×101×173 4
2025 12 08 20251208 2×2×2×743×3407 5
2025 12 09 20251209 3×11×613673 3
2025 12 10 20251210 2×5×7×7×37×1117 6
2025 12 11 20251211 20251211 1
2025 12 12 20251212 2×2×3×41×41161 5
2025 12 13 20251213 1063×19051 2
2025 12 14 20251214 2×151×67057 3
2025 12 15 20251215 3×3×3×3×5×31×1613 7
2025 12 16 20251216 2×2×2×2×17×74453 6
2025 12 17 20251217 7×2893031 2
2025 12 18 20251218 2×3×13×259631 4
2025 12 19 20251219 47×59×67×109 4
2025 12 20 20251220 2×2×5×11×92051 5
2025 12 21 20251221 3×6750407 2
2025 12 22 20251222 2×29×73×4783 4
2025 12 23 20251223 20251223 1
2025 12 24 20251224 2×2×2×3×3×7×23×1747 8
2025 12 25 20251225 5×5×810049 3
2025 12 26 20251226 2×19×409×1303 4
2025 12 27 20251227 3×6750409 2
2025 12 28 20251228 2×2×317×15971 4
2025 12 29 20251229 20251229 1
2025 12 30 20251230 2×3×5×241×2801 5
2025 12 31 20251231 7×11×13×20231 4

おまけ

素数×素数

  • 同じ素数同士の掛け算で日付になる数値(西暦0年から9999年までの範囲)を確認すると、その数はかなり少ない
  • 以下のようなプログラムで(抜粋)簡単に確認
  • 素数×素数で日付になるのはわずか55個
  • 1690年の後は2152年なので生きている間に回ってくる日付はない
    • たまたまだが、この2つの年は日付が同じ
    // ... 前略 ...
	private static int MAX=(int) (Math.ceil(Math.sqrt(100000000))+1);
    // ... 中略 ...
	private void primeNumberMultiple() {
		   SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
		   dateFormat.setLenient(false);
		   Date date;
		   int datenum=0;
		   for(int i : factors) {
			   String strNumber=String.format("%08d", i*i);
			   try {
				   date = dateFormat.parse(strNumber);
			   } catch (ParseException e) {
				   //System.out.println(String.format("%s is not date",strNumber));
				   continue;
			   }
    		   datenum++;
		       SimpleDateFormat getYearFormat = new SimpleDateFormat("yyyy");
		       SimpleDateFormat getMonthFormat = new SimpleDateFormat("MM");
		       SimpleDateFormat getDayFormat = new SimpleDateFormat("dd");
	    	   int number = Integer.parseInt(strNumber);
    		   String output = String.format("|%s|%s|%s|",
    				   getYearFormat.format(date),
    				   getMonthFormat.format(date),
    				   getDayFormat.format(date));
    		   System.out.println(output);

//			   System.out.println(String.format("%s is date",strNumber));
	       }
		   System.out.println(String.format("total count is : %d",datenum));
	}
    // ... 中略 ...
    	private void createFactors() {

		for(int i=2; i<=MAX; i++) {
			// 素数のみ格納する。
			if(isPrime(i,TRIAL_COUNT)) {
				factors.add(i);
			}
		}
		//outputFactors(factors,false,0);
	}
    // ... 後略 ...
0001 02 01
0001 06 09
0012 04 09
0016 08 01
0036 12 01
0110 04 01
0126 11 29
0163 07 29
0176 09 29
0207 07 21
0211 12 09
0255 04 09
0320 05 21
0534 07 21
0547 09 21
0565 01 29
0587 09 29
0723 07 21
0872 02 09
1258 12 09
1349 09 29
1352 03 29
1389 05 29
1398 01 21
1483 02 01
1503 11 29
1641 06 01
1690 03 21
2152 03 21
2303 04 01
2473 07 29
2511 01 21
2523 05 29
2602 02 01
2859 04 09
3026 10 01
3305 10 01
3421 08 01
3940 07 29
3998 03 29
4036 06 09
4493 02 09
4571 11 21
4628 08 09
4826 08 09
5735 03 29
5741 09 29
6485 08 09
6884 02 09
7477 06 09
7529 03 29
8012 04 01
8374 08 01
8951 05 21
9946 07 29
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
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?